@quantiya/codevibe-codex-plugin 2.0.63 → 2.0.65

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.
Files changed (59) hide show
  1. package/dist/server.js +38 -36
  2. package/node_modules/@quantiya/codevibe-core/dist/appsync/appsync-client.d.ts +302 -8
  3. package/node_modules/@quantiya/codevibe-core/dist/appsync/index.d.ts +25 -1
  4. package/node_modules/@quantiya/codevibe-core/dist/appsync/queries.d.ts +10 -0
  5. package/node_modules/@quantiya/codevibe-core/dist/appsync/standalone-companion-status.d.ts +6 -0
  6. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-deferred-inputs.d.ts +104 -0
  7. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-desktop-registration.d.ts +133 -0
  8. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-event-client.d.ts +110 -0
  9. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-inbound-journal.d.ts +142 -0
  10. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-input-delivery.d.ts +13 -0
  11. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-live-connection.d.ts +87 -0
  12. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-mobile-echo.d.ts +289 -0
  13. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-operation-journal.d.ts +236 -0
  14. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-prompt-publication.d.ts +153 -0
  15. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-prompt-resolution.d.ts +38 -0
  16. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-prompt-retention.d.ts +99 -0
  17. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-read-client.d.ts +131 -0
  18. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-resolution-recovery.d.ts +29 -0
  19. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-security-posture.d.ts +32 -0
  20. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-session-retirement.d.ts +30 -0
  21. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-shell-source.d.ts +151 -0
  22. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-source-cursor.d.ts +529 -0
  23. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-source-file.d.ts +33 -0
  24. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-source-pair.d.ts +33 -0
  25. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-state.d.ts +51 -0
  26. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-usage-warning.d.ts +33 -0
  27. package/node_modules/@quantiya/codevibe-core/dist/appsync/sync-workspace-outcome.d.ts +23 -0
  28. package/node_modules/@quantiya/codevibe-core/dist/config/config.d.ts +3 -0
  29. package/node_modules/@quantiya/codevibe-core/dist/credential-broker/oauth-account-lock.d.ts +4 -0
  30. package/node_modules/@quantiya/codevibe-core/dist/index.d.ts +26 -0
  31. package/node_modules/@quantiya/codevibe-core/dist/index.js +584 -537
  32. package/node_modules/@quantiya/codevibe-core/dist/local-executor/local-executor-impl.d.ts +11 -11
  33. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/cli.d.ts +9 -4
  34. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/cli.js +50680 -44643
  35. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/components/OrchestrationApp.d.ts +6 -0
  36. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/components/StatusBar.d.ts +2 -0
  37. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/decision-attempt-recovery.d.ts +2 -0
  38. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/emit-shell-event.d.ts +31 -8
  39. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/gate-prompts.d.ts +4 -0
  40. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/index.d.ts +8 -7
  41. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/planner-offer-e1.d.ts +5 -1
  42. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/quorum-loop.d.ts +9 -2
  43. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/shell-sync-recovery.d.ts +23 -0
  44. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/slash-routes/reviewers.d.ts +3 -1
  45. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/types.d.ts +8 -8
  46. package/node_modules/@quantiya/codevibe-core/dist/orchestration-shell/workspace-terminal-coordinator.d.ts +1 -1
  47. package/node_modules/@quantiya/codevibe-core/dist/planner/types.d.ts +2 -2
  48. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/atomic-file.d.ts +13 -3
  49. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/consolidator.d.ts +10 -2
  50. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/index.d.ts +1 -0
  51. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/ledger.d.ts +17 -9
  52. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/outbox.d.ts +20 -2
  53. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/replay-cursor.d.ts +2 -2
  54. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/sync-transport.d.ts +53 -0
  55. package/node_modules/@quantiya/codevibe-core/dist/tool-activity/types.d.ts +28 -24
  56. package/node_modules/@quantiya/codevibe-core/dist/types/events.d.ts +3 -0
  57. package/node_modules/@quantiya/codevibe-core/dist/types/reviewer.d.ts +14 -4
  58. package/node_modules/@quantiya/codevibe-core/package.json +1 -1
  59. package/package.json +2 -2
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ import type { DesktopSyncSessionScope } from './sync-operation-journal';
3
+ import { DesktopSyncReadClient, type DesktopSyncReadCredential, type DesktopSyncRegistrationAttempt, type SyncHistoryPage, type SyncReadEvent, type SyncRecoveryTarget } from './sync-read-client';
4
+ declare const record: z.ZodDiscriminatedUnion<"state", [z.ZodObject<{
5
+ state: z.ZodLiteral<"PENDING">;
6
+ clientOperationId: z.ZodString;
7
+ createdAtEpochMs: z.ZodNumber;
8
+ sessionId: z.ZodString;
9
+ sessionGenerationId: z.ZodString;
10
+ schemaVersion: z.ZodLiteral<1>;
11
+ kind: z.ZodLiteral<"DESKTOP_REGISTRATION">;
12
+ operationId: z.ZodString;
13
+ }, "strict", z.ZodTypeAny, {
14
+ kind: "DESKTOP_REGISTRATION";
15
+ sessionId: string;
16
+ sessionGenerationId: string;
17
+ clientOperationId: string;
18
+ schemaVersion: 1;
19
+ state: "PENDING";
20
+ operationId: string;
21
+ createdAtEpochMs: number;
22
+ }, {
23
+ kind: "DESKTOP_REGISTRATION";
24
+ sessionId: string;
25
+ sessionGenerationId: string;
26
+ clientOperationId: string;
27
+ schemaVersion: 1;
28
+ state: "PENDING";
29
+ operationId: string;
30
+ createdAtEpochMs: number;
31
+ }>, z.ZodObject<{
32
+ state: z.ZodLiteral<"READY">;
33
+ receipt: z.ZodObject<{
34
+ credential: z.ZodString;
35
+ expiresAtEpochMs: z.ZodNumber;
36
+ sessionId: z.ZodString;
37
+ sessionGenerationId: z.ZodString;
38
+ }, "strict", z.ZodTypeAny, {
39
+ sessionId: string;
40
+ sessionGenerationId: string;
41
+ credential: string;
42
+ expiresAtEpochMs: number;
43
+ }, {
44
+ sessionId: string;
45
+ sessionGenerationId: string;
46
+ credential: string;
47
+ expiresAtEpochMs: number;
48
+ }>;
49
+ clientOperationId: z.ZodString;
50
+ createdAtEpochMs: z.ZodNumber;
51
+ sessionId: z.ZodString;
52
+ sessionGenerationId: z.ZodString;
53
+ schemaVersion: z.ZodLiteral<1>;
54
+ kind: z.ZodLiteral<"DESKTOP_REGISTRATION">;
55
+ operationId: z.ZodString;
56
+ }, "strict", z.ZodTypeAny, {
57
+ kind: "DESKTOP_REGISTRATION";
58
+ sessionId: string;
59
+ sessionGenerationId: string;
60
+ clientOperationId: string;
61
+ schemaVersion: 1;
62
+ state: "READY";
63
+ operationId: string;
64
+ receipt: {
65
+ sessionId: string;
66
+ sessionGenerationId: string;
67
+ credential: string;
68
+ expiresAtEpochMs: number;
69
+ };
70
+ createdAtEpochMs: number;
71
+ }, {
72
+ kind: "DESKTOP_REGISTRATION";
73
+ sessionId: string;
74
+ sessionGenerationId: string;
75
+ clientOperationId: string;
76
+ schemaVersion: 1;
77
+ state: "READY";
78
+ operationId: string;
79
+ receipt: {
80
+ sessionId: string;
81
+ sessionGenerationId: string;
82
+ credential: string;
83
+ expiresAtEpochMs: number;
84
+ };
85
+ createdAtEpochMs: number;
86
+ }>]>;
87
+ export type DesktopSyncRegistrationRecord = z.infer<typeof record>;
88
+ export interface DesktopSyncRegistrationStore {
89
+ /** One durable operation per registration attempt; no periodic/network loop. */
90
+ credential(signal?: AbortSignal, revalidate?: boolean): Promise<DesktopSyncReadCredential>;
91
+ /** Exact stale credential only, after a typed server denial. A newer one is untouched. */
92
+ invalidate(stale: DesktopSyncReadCredential): Promise<boolean>;
93
+ /** Persist a validated socket receipt only for the credential that earned it. */
94
+ renew(current: DesktopSyncReadCredential, expiresAtEpochMs: number): Promise<DesktopSyncReadCredential>;
95
+ }
96
+ export declare function decodeDesktopSyncRegistration(value: unknown, invalid: () => never): DesktopSyncRegistrationRecord;
97
+ /** Uses the existing bounded encrypted journal, account fence and scoped lock.
98
+ * Persist only the immutable operation ID before sending. Each retry signs a
99
+ * fresh authorization time. Network failure retains an unresolved operation;
100
+ * only READY expiry or a typed server disposition retires an expired intent. */
101
+ export declare function createDesktopSyncRegistration(options: {
102
+ id: string;
103
+ scope: Readonly<DesktopSyncSessionScope>;
104
+ invalid(): never;
105
+ now(): number;
106
+ locked<T>(fn: (assertOwnership: () => Promise<void>) => Promise<T>): Promise<T>;
107
+ read(): Promise<DesktopSyncRegistrationRecord | null>;
108
+ write(row: DesktopSyncRegistrationRecord): Promise<void>;
109
+ register(attempt: DesktopSyncRegistrationAttempt, signal?: AbortSignal): Promise<DesktopSyncReadCredential>;
110
+ }): DesktopSyncRegistrationStore;
111
+ export interface DurableDesktopSyncReader {
112
+ credential(signal?: AbortSignal, revalidate?: boolean): Promise<DesktopSyncReadCredential>;
113
+ history(nextToken?: string, signal?: AbortSignal): Promise<SyncHistoryPage>;
114
+ gateResolution(promptId: string, signal?: AbortSignal): Promise<import('./sync-resolution-recovery').SyncResolutionResult>;
115
+ pendingInputs(nextToken?: string, signal?: AbortSignal): Promise<import('./sync-read-client').SyncPendingInputsPage>;
116
+ legacyPendingInputs(nextToken?: string, signal?: AbortSignal): Promise<import('./sync-read-client').SyncLegacyPendingInputsPage>;
117
+ pendingInput(target: import('./sync-read-client').SyncInputCoordinate, signal?: AbortSignal): Promise<SyncReadEvent | null>;
118
+ exact(target: {
119
+ eventId: string;
120
+ capability: string;
121
+ eventSha256: string;
122
+ }, signal?: AbortSignal): Promise<SyncReadEvent>;
123
+ recoverExact(target: SyncRecoveryTarget, signal?: AbortSignal): Promise<SyncReadEvent>;
124
+ recoverCurrent(target: SyncRecoveryTarget, signal?: AbortSignal): Promise<SyncReadEvent | null>;
125
+ executionReceipt(target: SyncRecoveryTarget, signal?: AbortSignal): Promise<import('./sync-read-client').SyncExecutedInput | null>;
126
+ renew(current: DesktopSyncReadCredential, expiresAtEpochMs: number): Promise<DesktopSyncReadCredential>;
127
+ close(): Promise<void>;
128
+ }
129
+ /** Live callers use this owner instead of managing an in-memory credential.
130
+ * A typed stale denial invalidates only the credential actually used. There
131
+ * is deliberately no implicit retry of history or a one-use exact fetch. */
132
+ export declare function createDurableDesktopSyncReader(client: DesktopSyncReadClient, registration: DesktopSyncRegistrationStore): DurableDesktopSyncReader;
133
+ export {};
@@ -0,0 +1,110 @@
1
+ import { type DeviceSigningKey } from '../local-executor/class-a-sign';
2
+ import type { WriterEventAttestationInput } from '../types/events';
3
+ export type SyncJson = null | boolean | number | string | SyncJson[] | {
4
+ [key: string]: SyncJson;
5
+ };
6
+ /** Mirrors the backend's closed customer-metered desktop status profile.
7
+ * Inclusion here never confers domain or CONTROL_ONLY authority. */
8
+ export declare const PLAIN_DESKTOP_SYNC_TYPES: readonly ["TOOL_ACTIVITY", "NOTIFICATION", "MODE_SELECTED", "PLANNER_DECISION", "PLANNER_CACHE_HIT", "PLANNER_DEGRADED", "PLANNER_OUTAGE", "PLANNER_RECOVERED", "SLASH_COMMAND_INVOKED", "STRUCTURAL_SUMMARY_GENERATED", "LOCAL_AUTHORITY_REFUSAL", "TEAM_DECOMPOSED", "TEAM_TRACK_STATUS", "TEAM_GROUP_RESOLVED"];
9
+ export type DesktopSyncEventType = 'USER_PROMPT' | 'ASSISTANT_RESPONSE' | 'REASONING' | 'TOOL_USE' | 'INTERACTIVE_PROMPT' | typeof PLAIN_DESKTOP_SYNC_TYPES[number];
10
+ export declare const isPlainDesktopSyncType: (type: unknown) => boolean;
11
+ interface SyncOperationIdentity {
12
+ /** Persist with the immutable operation before sending; never remint on retry. */
13
+ clientOperationId: string;
14
+ sessionId: string;
15
+ sessionGenerationId: string;
16
+ /** Use SESSION_KEY_GEN_ABSENT_SENTINEL only for a generation-absent session. */
17
+ expectedSessionKeyGen: string;
18
+ }
19
+ export type CreateDesktopSyncEventInput = SyncOperationIdentity & {
20
+ type: DesktopSyncEventType;
21
+ content?: string | null;
22
+ /** The JSON value, not an already AWSJSON-serialized string. Encrypted strings remain strings. */
23
+ metadata?: SyncJson;
24
+ /** Canonical UTC acceptance time, preserved through retries. Not an exact stored-key guarantee on collision. */
25
+ timestamp?: string;
26
+ /** Existing closed encrypted turn-writer profile; nonce equals clientOperationId. */
27
+ writerAttestation?: WriterEventAttestationInput;
28
+ /** Closed active-session E1 raise: all four fields required together. */
29
+ promptId?: string;
30
+ ownerToken?: string;
31
+ producerKind?: 'PLUGIN_APPROVAL' | 'CORE_OFFER';
32
+ mobileActionable?: boolean;
33
+ } & ({
34
+ isEncrypted: true;
35
+ encryptionVersion: 1;
36
+ } | {
37
+ isEncrypted: false;
38
+ encryptionVersion?: never;
39
+ });
40
+ export interface UpdateDesktopSyncEventInput extends SyncOperationIdentity {
41
+ eventId: string;
42
+ timestamp: string;
43
+ baseRevision: string;
44
+ immutableIdentityDigest: string;
45
+ metadataMerge: {
46
+ [key: string]: SyncJson;
47
+ };
48
+ }
49
+ export interface UpdateDesktopSyncStatusInput extends SyncOperationIdentity {
50
+ eventId: string;
51
+ timestamp: string;
52
+ deliveryStatus: 'DELIVERED' | 'EXECUTED';
53
+ }
54
+ /** Canonical control acknowledgement only; no fabricated Event payload. */
55
+ export interface SyncStatusReceipt {
56
+ sessionId: string;
57
+ sessionGenerationId: string;
58
+ eventId: string;
59
+ timestamp: string;
60
+ type: 'USER_PROMPT' | 'PROMPT_RESPONSE';
61
+ source: 'MOBILE';
62
+ deliveryStatus: 'DELIVERED' | 'EXECUTED';
63
+ deliveredAt: string;
64
+ executedAt?: string;
65
+ }
66
+ export type SyncPromptRetentionReceipt = {
67
+ promptId: string;
68
+ status: 'REFRESHED';
69
+ expiresAt: number;
70
+ } | {
71
+ promptId: string;
72
+ status: 'RERAISE_REQUIRED';
73
+ };
74
+ type DesktopSyncAction = 'CREATE_EVENT' | 'UPDATE_EVENT' | 'UPDATE_EVENT_STATUS';
75
+ /** Acceptance identity only. Deliberately not Event: no payload or delivery claim. */
76
+ export interface SyncEventReceipt {
77
+ eventId: string;
78
+ sessionId: string;
79
+ type: string;
80
+ source: 'DESKTOP' | 'MOBILE';
81
+ timestamp: string;
82
+ emittedBy: 'IMPLEMENTOR' | 'SYSTEM' | 'USER';
83
+ }
84
+ export declare class SyncEventClientError extends Error {
85
+ readonly code: 'INVALID_SYNC_INPUT' | 'INVALID_SYNC_RECEIPT' | 'INVALID_SYNC_STATE' | 'SYNC_IDENTITY_UNAVAILABLE' | 'SYNC_ACCOUNT_CHANGED' | 'SYNC_PRODUCER_FROZEN' | 'SYNC_SESSION_UNAVAILABLE' | 'SYNC_SESSION_GENERATION_CHANGED' | 'SYNC_SESSION_KEY_UNAVAILABLE';
86
+ constructor(code: 'INVALID_SYNC_INPUT' | 'INVALID_SYNC_RECEIPT' | 'INVALID_SYNC_STATE' | 'SYNC_IDENTITY_UNAVAILABLE' | 'SYNC_ACCOUNT_CHANGED' | 'SYNC_PRODUCER_FROZEN' | 'SYNC_SESSION_UNAVAILABLE' | 'SYNC_SESSION_GENERATION_CHANGED' | 'SYNC_SESSION_KEY_UNAVAILABLE');
87
+ }
88
+ export declare const SYNC_PROMPT_RAISE_FIELDS: readonly ["promptId", "ownerToken", "producerKind", "mobileActionable"];
89
+ /** Same closed commitment as the backend. No key/transport work is performed. */
90
+ export declare function snapshotSyncPromptRaise(value: Record<string, unknown>): {
91
+ promptId: string;
92
+ ownerToken: string;
93
+ producerKind: 'PLUGIN_APPROVAL' | 'CORE_OFFER';
94
+ mobileActionable: boolean;
95
+ } | undefined;
96
+ export declare function snapshotDesktopSyncInput(action: DesktopSyncAction, value: unknown): Record<string, SyncJson>;
97
+ /** Hash AppSync's decoded AWSJSON values; serialize AWSJSON exactly once afterward. */
98
+ export declare function signDesktopSyncInput(action: DesktopSyncAction | 'RESOLVE_PROMPT' | 'CONFIRM_RETIREMENT' | 'REPORT_SECURITY_POSTURE', data: Record<string, SyncJson>, userId: string, keys: DeviceSigningKey, issuedAtEpochMs: number): Readonly<Record<string, unknown>>;
99
+ /** The optional server transition hint is not persisted as an Event receipt
100
+ * and never grants a route, quota or local PAUSED state. */
101
+ export declare function parseSyncEventMutationResponse(value: unknown, expected: Record<string, SyncJson>): {
102
+ receipt: SyncEventReceipt;
103
+ refreshSyncState: boolean;
104
+ };
105
+ export declare function parseSyncEventReceipt(value: unknown, expected: Record<string, SyncJson>): SyncEventReceipt;
106
+ export declare function parseSyncStatusReceipt(value: unknown, expected: Record<string, SyncJson>): SyncStatusReceipt;
107
+ /** Only a canonical absence receipt permits re-raise; denial, malformed data,
108
+ * and an uncertain transaction outcome must never be interpreted as absence. */
109
+ export declare function parseSyncPromptRetentionReceipt(value: unknown, promptId: string): SyncPromptRetentionReceipt;
110
+ export {};
@@ -0,0 +1,142 @@
1
+ import { z } from 'zod';
2
+ import type { DesktopSyncSessionScope } from './sync-operation-journal';
3
+ import type { SyncReadEvent, SyncRecoveryTarget } from './sync-read-client';
4
+ declare const schema: z.ZodObject<{
5
+ schemaVersion: z.ZodLiteral<1>;
6
+ kind: z.ZodLiteral<"DESKTOP_INBOUND">;
7
+ operationId: z.ZodString;
8
+ sessionId: z.ZodString;
9
+ sessionGenerationId: z.ZodString;
10
+ entries: z.ZodArray<z.ZodObject<{
11
+ target: z.ZodObject<{
12
+ eventId: z.ZodString;
13
+ timestamp: z.ZodEffects<z.ZodString, string, string>;
14
+ eventRevision: z.ZodEffects<z.ZodString, string, string>;
15
+ eventSha256: z.ZodString;
16
+ }, "strict", z.ZodTypeAny, {
17
+ eventId: string;
18
+ timestamp: string;
19
+ eventSha256: string;
20
+ eventRevision: string;
21
+ }, {
22
+ eventId: string;
23
+ timestamp: string;
24
+ eventSha256: string;
25
+ eventRevision: string;
26
+ }>;
27
+ state: z.ZodEnum<["RECEIVED", "DISPATCHING", "HANDED_OFF", "UNCERTAIN"]>;
28
+ remoteExecuted: z.ZodBoolean;
29
+ localExecuted: z.ZodDefault<z.ZodBoolean>;
30
+ }, "strict", z.ZodTypeAny, {
31
+ state: "RECEIVED" | "DISPATCHING" | "HANDED_OFF" | "UNCERTAIN";
32
+ target: {
33
+ eventId: string;
34
+ timestamp: string;
35
+ eventSha256: string;
36
+ eventRevision: string;
37
+ };
38
+ remoteExecuted: boolean;
39
+ localExecuted: boolean;
40
+ }, {
41
+ state: "RECEIVED" | "DISPATCHING" | "HANDED_OFF" | "UNCERTAIN";
42
+ target: {
43
+ eventId: string;
44
+ timestamp: string;
45
+ eventSha256: string;
46
+ eventRevision: string;
47
+ };
48
+ remoteExecuted: boolean;
49
+ localExecuted?: boolean | undefined;
50
+ }>, "many">;
51
+ }, "strict", z.ZodTypeAny, {
52
+ kind: "DESKTOP_INBOUND";
53
+ entries: {
54
+ state: "RECEIVED" | "DISPATCHING" | "HANDED_OFF" | "UNCERTAIN";
55
+ target: {
56
+ eventId: string;
57
+ timestamp: string;
58
+ eventSha256: string;
59
+ eventRevision: string;
60
+ };
61
+ remoteExecuted: boolean;
62
+ localExecuted: boolean;
63
+ }[];
64
+ sessionId: string;
65
+ sessionGenerationId: string;
66
+ schemaVersion: 1;
67
+ operationId: string;
68
+ }, {
69
+ kind: "DESKTOP_INBOUND";
70
+ entries: {
71
+ state: "RECEIVED" | "DISPATCHING" | "HANDED_OFF" | "UNCERTAIN";
72
+ target: {
73
+ eventId: string;
74
+ timestamp: string;
75
+ eventSha256: string;
76
+ eventRevision: string;
77
+ };
78
+ remoteExecuted: boolean;
79
+ localExecuted?: boolean | undefined;
80
+ }[];
81
+ sessionId: string;
82
+ sessionGenerationId: string;
83
+ schemaVersion: 1;
84
+ operationId: string;
85
+ }>;
86
+ export type DesktopInboundRecord = z.infer<typeof schema>;
87
+ export declare class SyncInboundError extends Error {
88
+ readonly code: 'SYNC_INBOUND_INVALID' | 'SYNC_INBOUND_FULL' | 'SYNC_INBOUND_UNCERTAIN';
89
+ constructor(code: 'SYNC_INBOUND_INVALID' | 'SYNC_INBOUND_FULL' | 'SYNC_INBOUND_UNCERTAIN');
90
+ }
91
+ export declare function decodeDesktopInbound(value: unknown): DesktopInboundRecord;
92
+ export interface DesktopInboundJournal {
93
+ /** Fsync a known coordinate before consuming its one-use capability. */
94
+ stage(value: SyncRecoveryTarget): Promise<'RECEIVED' | 'RETAINED'>;
95
+ /** Observe a current authenticated pending input, not an unverified hint.
96
+ * Unknown DELIVERED inputs are uncertain and must never be replayed. */
97
+ stageDiscovered(event: SyncReadEvent): Promise<'RECEIVED' | 'RETAINED'>;
98
+ /** Refresh an existing never-dispatched coordinate from current authority. */
99
+ refreshReceived(event: SyncReadEvent): Promise<'RECEIVED' | 'RETAINED'>;
100
+ /** A missing canonical row is not permission to execute a cached input. */
101
+ retainMissing(value: SyncRecoveryTarget): Promise<void>;
102
+ /** Only never-dispatched coordinates are safe to recover automatically. */
103
+ recoverable(): Promise<{
104
+ pending: readonly SyncRecoveryTarget[];
105
+ uncertain: number;
106
+ }>;
107
+ /** Coordinates only. Their payload must never be sent to a provider again. */
108
+ pendingAcknowledgements(): Promise<readonly SyncRecoveryTarget[]>;
109
+ /** Only a completed local handoff authorizes retrying its status write.
110
+ * An uncertain provider action is never converted into local success. */
111
+ hasCompletedHandoff(value: SyncRecoveryTarget): Promise<boolean>;
112
+ /** Persist the provider's explicit EXECUTED claim before cloud I/O.
113
+ * Callback completion alone may mean queued or rejected, not executed. */
114
+ markExecutedLocally(event: Parameters<DesktopInboundJournal['acknowledgeExecuted']>[0]): Promise<boolean>;
115
+ dispatch(event: SyncReadEvent, callback: () => Promise<void> | void, signal?: AbortSignal): Promise<'HANDED_OFF' | 'RETAINED'>;
116
+ /** A verified non-input needs no terminal-input handoff receipt. */
117
+ releaseNonInput(event: SyncReadEvent): Promise<void>;
118
+ /** Call only with a canonical cloud EXECUTED result, never a local send claim. */
119
+ acknowledgeExecuted(event: {
120
+ eventId: string;
121
+ timestamp: string;
122
+ sessionId: string;
123
+ sessionGenerationId: string;
124
+ source: string;
125
+ type: string;
126
+ deliveryStatus: string;
127
+ }): Promise<boolean>;
128
+ }
129
+ /** Shared journal persistence supplies encryption, account fencing and capacity.
130
+ * The short record lock never spans provider I/O; a distinct handoff lock does.
131
+ * A crash after DISPATCHING is uncertain, not permission to repeat terminal input.
132
+ * Healthy entries leave only after cloud EXECUTED + local handoff completion.
133
+ * The 64-entry limit bounds unresolved inputs, not lifetime session traffic. */
134
+ export declare function createDesktopInbound(options: {
135
+ id: string;
136
+ scope: Readonly<DesktopSyncSessionScope>;
137
+ locked<T>(fn: (assertOwnership: () => Promise<void>) => Promise<T>): Promise<T>;
138
+ dispatchLocked<T>(fn: (assertOwnership: () => Promise<void>) => Promise<T>): Promise<T>;
139
+ read(): Promise<DesktopInboundRecord | null>;
140
+ write(row: DesktopInboundRecord): Promise<void>;
141
+ }): DesktopInboundJournal;
142
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type Event, type UpdateEventStatusInput } from '../types/events';
2
+ import { type SyncStatusReceipt } from './sync-event-client';
3
+ export type MobileInputStatusUpdater = (input: UpdateEventStatusInput, requiredInput?: Pick<SyncStatusReceipt, 'sessionGenerationId' | 'type'>) => Promise<unknown>;
4
+ /** The lifecycle marker comes from the authenticated R2 reader, never metadata. */
5
+ export declare function requiresSyncInputDeliveryReceipt(event: Event): boolean;
6
+ /**
7
+ * Before any terminal/planner side effect, require the exact cloud delivery
8
+ * receipt for R2. EXECUTED means a previous handoff won: do not route again.
9
+ * Legacy callers retain their existing best-effort error policy.
10
+ */
11
+ export declare function acknowledgeMobileInputDelivery(update: MobileInputStatusUpdater, event: Event): Promise<boolean>;
12
+ /** Validate the exact post-handoff receipt; failure must retain the tombstone. */
13
+ export declare function acknowledgeMobileInputExecution(update: MobileInputStatusUpdater, event: Event): Promise<void>;
@@ -0,0 +1,87 @@
1
+ import WebSocket from 'ws';
2
+ import { DesktopSyncReadClient, type SyncReadEvent, type SyncRecoveryTarget, type SyncExecutedInput } from './sync-read-client';
3
+ import type { DurableDesktopSyncReader } from './sync-desktop-registration';
4
+ import type { DesktopSyncSessionScope } from './sync-operation-journal';
5
+ import type { DesktopInboundJournal } from './sync-inbound-journal';
6
+ /** One connection only. The existing subscription owner controls reconnects.
7
+ * Frames/hints are bounded before parsing; exact capabilities are never retried.
8
+ * Lost fetches use one charged exact-coordinate history request; ordinary
9
+ * history remains explicit and is never replayed into the agent callback. */
10
+ export declare class DesktopSyncLiveConnection {
11
+ private readonly deps;
12
+ private readonly scope;
13
+ private readonly endpoint;
14
+ private readonly abort;
15
+ private ws?;
16
+ private credential?;
17
+ private generation?;
18
+ private phase;
19
+ private starting?;
20
+ private closing?;
21
+ private resolveReady?;
22
+ private rejectReady?;
23
+ private controlTimer?;
24
+ private pingTimer?;
25
+ private pongTimer?;
26
+ private heartbeatTimer?;
27
+ private recoveryTimer?;
28
+ private recoveryCursor?;
29
+ private recoveryItems;
30
+ private recoveryPages;
31
+ private legacyRecoveryActive;
32
+ private legacyRecoveryComplete;
33
+ private legacyRecoveryCursor?;
34
+ private legacyRecoveryItems;
35
+ private acknowledgementDueAt;
36
+ private acknowledgementAfter?;
37
+ private acknowledgementItems;
38
+ private pingNonce?;
39
+ private tail;
40
+ private statusRefresh?;
41
+ private queued;
42
+ private readonly seen;
43
+ private readonly beforeHello;
44
+ constructor(deps: {
45
+ endpoint: string;
46
+ environment: 'development' | 'production';
47
+ scope: DesktopSyncSessionScope;
48
+ wire: DesktopSyncReadClient;
49
+ reader: DurableDesktopSyncReader;
50
+ assertAccount(): void;
51
+ inbound: DesktopInboundJournal;
52
+ onUncertain?(count: number): void;
53
+ retryExecutionAcknowledgement?(target: SyncRecoveryTarget, signal: AbortSignal): Promise<SyncExecutedInput>;
54
+ onMaintenance?(signal: AbortSignal): Promise<void>;
55
+ onEvent(event: SyncReadEvent): Promise<void> | void;
56
+ onError(error: Error): void;
57
+ openSocket?: (url: string, options: WebSocket.ClientOptions) => WebSocket;
58
+ now?: () => number;
59
+ });
60
+ private now;
61
+ private fence;
62
+ private sameScope;
63
+ start(): Promise<void>;
64
+ private deadline;
65
+ private sendControl;
66
+ private message;
67
+ private enqueue;
68
+ /** Display recovery uses the existing accepted heartbeat, not another poll.
69
+ * It never gates readiness, input delivery, or connection maintenance. */
70
+ private refreshStatus;
71
+ private reconcileReceived;
72
+ private deliver;
73
+ /** One coordinate per queued step, yielding to live hints between steps.
74
+ * A completed handoff may also retry its fenced status-only acknowledgement.
75
+ * At most four 32-coordinate pages per burst; no Event bodies accumulate.
76
+ * Cursor is pagination only. Each completed pass restarts at the beginning
77
+ * after five minutes, including when a commit had an older timestamp. */
78
+ private scheduleDiscovery;
79
+ private discoveryStep;
80
+ private reconcileAcknowledgement;
81
+ private legacyDiscoveryStep;
82
+ private discoverCoordinate;
83
+ private startPings;
84
+ private fail;
85
+ history(nextToken?: string, signal?: AbortSignal): Promise<import("./sync-read-client").SyncHistoryPage>;
86
+ close(): Promise<void>;
87
+ }