@getpaseo/server 0.9.0-beta.1 → 0.9.0-beta.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/dist/server/server/agent/agent-loading.js +5 -2
- package/dist/server/server/agent/agent-manager.d.ts +2 -1
- package/dist/server/server/agent/agent-manager.js +10 -8
- package/dist/server/server/agent/agent-projections.d.ts +0 -1
- package/dist/server/server/agent/agent-projections.js +2 -16
- package/dist/server/server/persistence-hooks.d.ts +15 -0
- package/dist/server/server/persistence-hooks.js +37 -1
- package/dist/server/server/session.js +4 -4
- package/dist/server/web-ui/_expo/static/js/web/{index-00c76d618861eb00a8e1e822dfcadf7e.js → index-81fd85915b2feba2f0f2522cbeaaf74b.js} +4 -4
- package/dist/server/web-ui/_expo/static/js/web/index-81fd85915b2feba2f0f2522cbeaaf74b.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-81fd85915b2feba2f0f2522cbeaaf74b.js.gz +0 -0
- package/dist/server/web-ui/index.html +1 -1
- package/dist/server/web-ui/index.html.br +0 -0
- package/dist/server/web-ui/index.html.gz +0 -0
- package/package.json +6 -6
- package/dist/server/web-ui/_expo/static/js/web/index-00c76d618861eb00a8e1e822dfcadf7e.js.br +0 -0
- package/dist/server/web-ui/_expo/static/js/web/index-00c76d618861eb00a8e1e822dfcadf7e.js.gz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildConfigOverrides, buildSessionConfig, extractTimestamps, isStoredAgentProviderAvailable, toAgentPersistenceHandle, } from "../persistence-hooks.js";
|
|
1
|
+
import { buildConfigOverrides, buildSessionConfig, extractAttention, extractTimestamps, isStoredAgentProviderAvailable, toAgentPersistenceHandle, } from "../persistence-hooks.js";
|
|
2
2
|
const pendingAgentInitializations = new Map();
|
|
3
3
|
export async function ensureUnarchivedAgentLoaded(agentId, deps) {
|
|
4
4
|
const record = await deps.agentStorage.get(agentId);
|
|
@@ -51,10 +51,13 @@ export async function ensureAgentLoaded(agentId, deps) {
|
|
|
51
51
|
const handle = toAgentPersistenceHandle(validProviders, record.persistence);
|
|
52
52
|
let snapshot;
|
|
53
53
|
if (handle) {
|
|
54
|
-
snapshot = await deps.agentManager.resumeAgentFromPersistence(handle, buildConfigOverrides(record), agentId, extractTimestamps(record), record.archivedAt ? { purpose: "history" } : undefined);
|
|
54
|
+
snapshot = await deps.agentManager.resumeAgentFromPersistence(handle, buildConfigOverrides(record), agentId, { ...extractTimestamps(record), attention: extractAttention(record) }, record.archivedAt ? { purpose: "history" } : undefined);
|
|
55
55
|
deps.logger.info({ agentId, provider: record.provider }, "Agent resumed from persistence");
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
+
// No provider handle to resume: this starts the agent's first session rather than
|
|
59
|
+
// bringing one back, so it stamps activity and carries no stored attention. Records
|
|
60
|
+
// without a handle never got far enough to accumulate either.
|
|
58
61
|
const config = buildSessionConfig(record, {
|
|
59
62
|
validProviders,
|
|
60
63
|
});
|
|
@@ -150,7 +150,7 @@ export interface WaitForAgentResult {
|
|
|
150
150
|
export interface WaitForAgentStartOptions {
|
|
151
151
|
signal?: AbortSignal;
|
|
152
152
|
}
|
|
153
|
-
type AttentionState = {
|
|
153
|
+
export type AttentionState = {
|
|
154
154
|
requiresAttention: false;
|
|
155
155
|
} | {
|
|
156
156
|
requiresAttention: true;
|
|
@@ -333,6 +333,7 @@ export declare class AgentManager {
|
|
|
333
333
|
labels?: Record<string, string>;
|
|
334
334
|
workspaceId?: string;
|
|
335
335
|
owner?: AgentOwner;
|
|
336
|
+
attention?: AttentionState;
|
|
336
337
|
}, resumeOptions?: AgentResumeSessionOptions): Promise<ManagedAgent>;
|
|
337
338
|
private resumeAgentFromPersistenceInternal;
|
|
338
339
|
importProviderSession(input: {
|
|
@@ -20,6 +20,7 @@ import { resolveCreateAgentTitles } from "./create-agent-title.js";
|
|
|
20
20
|
import { isPaseoToolPolicyEnabled } from "./paseo-tool-policy.js";
|
|
21
21
|
import { ProviderSubagentStore, } from "./provider-subagents/store.js";
|
|
22
22
|
import { withTimeout } from "../../utils/promise-timeout.js";
|
|
23
|
+
import { extractAttention } from "../persistence-hooks.js";
|
|
23
24
|
const RELOAD_SESSION_CLOSE_TIMEOUT_MS = 3000;
|
|
24
25
|
const INTERRUPT_SESSION_TIMEOUT_MS = 2000;
|
|
25
26
|
const IMPORTABLE_SESSION_LIST_TIMEOUT_MS = 90000;
|
|
@@ -737,6 +738,7 @@ export class AgentManager {
|
|
|
737
738
|
return this.registerSession(session, storedConfig, resolvedAgentId, {
|
|
738
739
|
...options,
|
|
739
740
|
persistence: handle,
|
|
741
|
+
restoring: true,
|
|
740
742
|
});
|
|
741
743
|
}
|
|
742
744
|
importProviderSession(input) {
|
|
@@ -865,6 +867,7 @@ export class AgentManager {
|
|
|
865
867
|
lastUsage: preservedLastUsage,
|
|
866
868
|
lastError: preservedLastError,
|
|
867
869
|
attention: preservedAttention,
|
|
870
|
+
restoring: true,
|
|
868
871
|
});
|
|
869
872
|
}
|
|
870
873
|
catch (error) {
|
|
@@ -1112,13 +1115,7 @@ export class AgentManager {
|
|
|
1112
1115
|
}
|
|
1113
1116
|
dispatchStoredAgentState(record) {
|
|
1114
1117
|
const updatedAt = new Date(record.updatedAt);
|
|
1115
|
-
const attention = record
|
|
1116
|
-
? {
|
|
1117
|
-
requiresAttention: true,
|
|
1118
|
-
attentionReason: record.attentionReason,
|
|
1119
|
-
attentionTimestamp: new Date(record.attentionTimestamp),
|
|
1120
|
-
}
|
|
1121
|
-
: { requiresAttention: false };
|
|
1118
|
+
const attention = extractAttention(record);
|
|
1122
1119
|
this.dispatch({
|
|
1123
1120
|
type: "agent_state",
|
|
1124
1121
|
agent: {
|
|
@@ -2405,7 +2402,12 @@ export class AgentManager {
|
|
|
2405
2402
|
await this.refreshSessionState(managed, { emit: false });
|
|
2406
2403
|
this.assertAgentRegistrationActive(managed);
|
|
2407
2404
|
managed.lifecycle = "idle";
|
|
2408
|
-
|
|
2405
|
+
// Stamping now over a restored timestamp rewrote the workspace's "last used" in the
|
|
2406
|
+
// sidebar every time a chat was reopened, because workspace `statusEnteredAt` is
|
|
2407
|
+
// re-derived from persisted agent `updatedAt` on every daemon start.
|
|
2408
|
+
if (!options?.restoring) {
|
|
2409
|
+
this.touchUpdatedAt(managed);
|
|
2410
|
+
}
|
|
2409
2411
|
await this.persistSnapshot(managed);
|
|
2410
2412
|
this.assertAgentRegistrationActive(managed);
|
|
2411
2413
|
this.emitState(managed, { persist: false });
|
|
@@ -22,5 +22,4 @@ export declare function toAgentListItemPayload(agent: AgentSnapshotPayload): Age
|
|
|
22
22
|
export declare function toRecentProviderSessionDescriptorPayload(session: ImportableProviderSession & {
|
|
23
23
|
provider: string;
|
|
24
24
|
}, options: RecentProviderSessionProjectionOptions): RecentProviderSessionDescriptorPayload;
|
|
25
|
-
export declare function resolveStoredAgentPayloadUpdatedAt(record: StoredAgentRecord): string;
|
|
26
25
|
//# sourceMappingURL=agent-projections.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isStoredAgentProviderAvailable, toAgentPersistenceHandle } from "../persistence-hooks.js";
|
|
1
|
+
import { isStoredAgentProviderAvailable, resolveStoredAgentUpdatedAt, toAgentPersistenceHandle, } from "../persistence-hooks.js";
|
|
2
2
|
function normalizeThinkingOptionId(value) {
|
|
3
3
|
if (typeof value !== "string")
|
|
4
4
|
return null;
|
|
@@ -145,7 +145,7 @@ export function buildStoredAgentPayload(record, validProviders) {
|
|
|
145
145
|
supportsRewindBoth: false,
|
|
146
146
|
};
|
|
147
147
|
const createdAt = new Date(record.createdAt);
|
|
148
|
-
const updatedAt = new Date(
|
|
148
|
+
const updatedAt = new Date(resolveStoredAgentUpdatedAt(record));
|
|
149
149
|
const lastUserMessageAt = record.lastUserMessageAt ? new Date(record.lastUserMessageAt) : null;
|
|
150
150
|
const runtimeInfo = buildStoredRuntimeInfo(record);
|
|
151
151
|
const providerAvailable = isStoredAgentProviderAvailable(record, validProviders);
|
|
@@ -214,20 +214,6 @@ export function toRecentProviderSessionDescriptorPayload(session, options) {
|
|
|
214
214
|
lastActivityAt: session.lastActivityAt.toISOString(),
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
|
-
export function resolveStoredAgentPayloadUpdatedAt(record) {
|
|
218
|
-
const timestamps = [record.updatedAt, record.lastActivityAt]
|
|
219
|
-
.filter((value) => typeof value === "string" && value.length > 0)
|
|
220
|
-
.map((value) => ({
|
|
221
|
-
raw: value,
|
|
222
|
-
parsed: Date.parse(value),
|
|
223
|
-
}))
|
|
224
|
-
.filter((value) => !Number.isNaN(value.parsed));
|
|
225
|
-
if (timestamps.length === 0) {
|
|
226
|
-
return record.updatedAt;
|
|
227
|
-
}
|
|
228
|
-
timestamps.sort((a, b) => b.parsed - a.parsed);
|
|
229
|
-
return timestamps[0].raw;
|
|
230
|
-
}
|
|
231
217
|
function buildSerializableConfig(config) {
|
|
232
218
|
const serializable = {};
|
|
233
219
|
if (config.modeId) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentManager } from "./agent/agent-manager.js";
|
|
2
2
|
import type { AgentPersistenceHandle, AgentProvider, AgentSessionConfig } from "./agent/agent-sdk-types.js";
|
|
3
3
|
import type { AgentStorage, StoredAgentRecord } from "./agent/agent-storage.js";
|
|
4
|
+
import type { AttentionState } from "./agent/agent-manager.js";
|
|
4
5
|
interface LoggerLike {
|
|
5
6
|
child(bindings: Record<string, unknown>): LoggerLike;
|
|
6
7
|
error(...args: unknown[]): void;
|
|
@@ -19,6 +20,14 @@ export declare function attachAgentStoragePersistence(logger: LoggerLike, agentM
|
|
|
19
20
|
export declare function buildConfigOverrides(record: StoredAgentRecord): Partial<AgentSessionConfig>;
|
|
20
21
|
export declare function buildSessionConfig(record: StoredAgentRecord, options?: BuildSessionConfigOptions): AgentSessionConfig | null;
|
|
21
22
|
export declare function isStoredAgentProviderAvailable(record: StoredAgentRecord, validProviders?: Iterable<AgentProvider>): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* When the record last changed, from either of the two timestamps it carries. They diverge
|
|
25
|
+
* because renaming, labelling, restoring from archive, marking unread, and clearing attention
|
|
26
|
+
* all move `updatedAt` on an unloaded agent without touching `lastActivityAt`. Reading one
|
|
27
|
+
* field alone hands consumers a time older than one they have already seen, and
|
|
28
|
+
* `acceptAgentDirectoryUpdate` drops every state update that goes backwards.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveStoredAgentUpdatedAt(record: StoredAgentRecord): string;
|
|
22
31
|
export declare function extractTimestamps(record: StoredAgentRecord): {
|
|
23
32
|
createdAt: Date;
|
|
24
33
|
updatedAt: Date;
|
|
@@ -27,6 +36,12 @@ export declare function extractTimestamps(record: StoredAgentRecord): {
|
|
|
27
36
|
workspaceId?: string;
|
|
28
37
|
owner?: StoredAgentRecord["owner"];
|
|
29
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Unread state survives a resume. Attention is set by the agent finishing or failing and
|
|
41
|
+
* cleared by the user reading the chat (`workspace.clear_attention`); reloading the runtime
|
|
42
|
+
* is neither, so a resumed agent that drops it silently marks the chat read.
|
|
43
|
+
*/
|
|
44
|
+
export declare function extractAttention(record: StoredAgentRecord): AttentionState;
|
|
30
45
|
export declare function toAgentPersistenceHandle(registeredProviders: Iterable<AgentProvider>, handle: StoredAgentRecord["persistence"]): AgentPersistenceHandle | null;
|
|
31
46
|
export {};
|
|
32
47
|
//# sourceMappingURL=persistence-hooks.d.ts.map
|
|
@@ -65,16 +65,52 @@ export function buildSessionConfig(record, options) {
|
|
|
65
65
|
export function isStoredAgentProviderAvailable(record, validProviders) {
|
|
66
66
|
return isProviderRegistered(validProviders, record.provider);
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* When the record last changed, from either of the two timestamps it carries. They diverge
|
|
70
|
+
* because renaming, labelling, restoring from archive, marking unread, and clearing attention
|
|
71
|
+
* all move `updatedAt` on an unloaded agent without touching `lastActivityAt`. Reading one
|
|
72
|
+
* field alone hands consumers a time older than one they have already seen, and
|
|
73
|
+
* `acceptAgentDirectoryUpdate` drops every state update that goes backwards.
|
|
74
|
+
*/
|
|
75
|
+
export function resolveStoredAgentUpdatedAt(record) {
|
|
76
|
+
const timestamps = [record.updatedAt, record.lastActivityAt]
|
|
77
|
+
.filter((value) => typeof value === "string" && value.length > 0)
|
|
78
|
+
.map((value) => ({
|
|
79
|
+
raw: value,
|
|
80
|
+
parsed: Date.parse(value),
|
|
81
|
+
}))
|
|
82
|
+
.filter((value) => !Number.isNaN(value.parsed));
|
|
83
|
+
if (timestamps.length === 0) {
|
|
84
|
+
return record.updatedAt;
|
|
85
|
+
}
|
|
86
|
+
timestamps.sort((a, b) => b.parsed - a.parsed);
|
|
87
|
+
return timestamps[0].raw;
|
|
88
|
+
}
|
|
68
89
|
export function extractTimestamps(record) {
|
|
69
90
|
return {
|
|
70
91
|
createdAt: new Date(record.createdAt),
|
|
71
|
-
updatedAt: new Date(record
|
|
92
|
+
updatedAt: new Date(resolveStoredAgentUpdatedAt(record)),
|
|
72
93
|
lastUserMessageAt: record.lastUserMessageAt ? new Date(record.lastUserMessageAt) : null,
|
|
73
94
|
labels: record.labels,
|
|
74
95
|
workspaceId: record.workspaceId,
|
|
75
96
|
owner: record.owner,
|
|
76
97
|
};
|
|
77
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Unread state survives a resume. Attention is set by the agent finishing or failing and
|
|
101
|
+
* cleared by the user reading the chat (`workspace.clear_attention`); reloading the runtime
|
|
102
|
+
* is neither, so a resumed agent that drops it silently marks the chat read.
|
|
103
|
+
*/
|
|
104
|
+
export function extractAttention(record) {
|
|
105
|
+
if (!record.requiresAttention || !record.attentionReason || !record.attentionTimestamp) {
|
|
106
|
+
return { requiresAttention: false };
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
requiresAttention: true,
|
|
110
|
+
attentionReason: record.attentionReason,
|
|
111
|
+
attentionTimestamp: new Date(record.attentionTimestamp),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
78
114
|
export function toAgentPersistenceHandle(registeredProviders, handle) {
|
|
79
115
|
if (!handle) {
|
|
80
116
|
return null;
|
|
@@ -15,7 +15,7 @@ import { TerminalSessionController } from "../terminal/terminal-session-controll
|
|
|
15
15
|
import { CursorError } from "./pagination/cursor.js";
|
|
16
16
|
import { SortablePager } from "./pagination/sortable-pager.js";
|
|
17
17
|
import { matchesAgentHistoryQuery } from "./agent-history-search.js";
|
|
18
|
-
import { buildConfigOverrides, isStoredAgentProviderAvailable, toAgentPersistenceHandle, } from "./persistence-hooks.js";
|
|
18
|
+
import { buildConfigOverrides, isStoredAgentProviderAvailable, resolveStoredAgentUpdatedAt, toAgentPersistenceHandle, } from "./persistence-hooks.js";
|
|
19
19
|
import { ensureAgentLoaded, ensureUnarchivedAgentLoaded } from "./agent/agent-loading.js";
|
|
20
20
|
import { sendPromptToAgent, waitForAgentRunStartWithTimeout, unarchiveAgentState, } from "./agent/agent-prompt.js";
|
|
21
21
|
import { resolveCreateAgentTitles, resolveFirstAgentPromptTitle, } from "./agent/create-agent-title.js";
|
|
@@ -36,7 +36,7 @@ import { buildTimelinePromptIndex } from "./agent/timeline-prompt-index.js";
|
|
|
36
36
|
import { createAgentCommand } from "./agent/create-agent/create.js";
|
|
37
37
|
import { resolveCreateAgentIntent } from "./agent/create-agent/intent.js";
|
|
38
38
|
import { archiveAgentCommand, cancelAgentRunCommand, closeAgentCommand, detachAgentCommand, setAgentModeCommand, updateAgentCommand, } from "./agent/lifecycle-command.js";
|
|
39
|
-
import { buildStoredAgentPayload,
|
|
39
|
+
import { buildStoredAgentPayload, toAgentPayload } from "./agent/agent-projections.js";
|
|
40
40
|
import { appendTimelineItemIfAgentKnown, emitLiveTimelineItemIfAgentKnown, } from "./agent/timeline-append.js";
|
|
41
41
|
import { assertPluginTimelineDataSize } from "./agent/agent-timeline-content.js";
|
|
42
42
|
import { parsePluginClientId } from "./plugins/plugin-session-identity.js";
|
|
@@ -2387,8 +2387,8 @@ export class Session {
|
|
|
2387
2387
|
if (!latest) {
|
|
2388
2388
|
return candidate;
|
|
2389
2389
|
}
|
|
2390
|
-
const updatedDelta = Date.parse(
|
|
2391
|
-
Date.parse(
|
|
2390
|
+
const updatedDelta = Date.parse(resolveStoredAgentUpdatedAt(candidate)) -
|
|
2391
|
+
Date.parse(resolveStoredAgentUpdatedAt(latest));
|
|
2392
2392
|
if (updatedDelta !== 0) {
|
|
2393
2393
|
return updatedDelta > 0 ? candidate : latest;
|
|
2394
2394
|
}
|
|
@@ -822,7 +822,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v
|
|
|
822
822
|
__d(function(g,r,i,a,m,e,d){"use strict";var t=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.shouldAppendSitemap=u,e.shouldAppendNotFound=s,e.getRootStackRouteNames=function(){const t=[n.INTERNAL_SLOT_NAME];s()&&t.push(n.NOT_FOUND_ROUTE_NAME);u()&&t.push(n.SITEMAP_ROUTE_NAME);return t};const o=t(r(d[0])),n=r(d[1]);function u(){const t=o.default.expoConfig?.extra?.router;return!1!==t?.sitemap}function s(){const t=o.default.expoConfig?.extra?.router;return!1!==t?.notFound}},700,[701,704]);
|
|
823
823
|
__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"AppOwnership",{enumerable:!0,get:function(){return l.AppOwnership}}),Object.defineProperty(_e,"ExecutionEnvironment",{enumerable:!0,get:function(){return l.ExecutionEnvironment}}),Object.defineProperty(_e,"UserInterfaceIdiom",{enumerable:!0,get:function(){return l.UserInterfaceIdiom}});var n=e(r(d[0])),t=r(d[1]);r(d[2]);var u=e(r(d[3])),l=r(d[4]),o=e(r(d[5]));o.default||console.warn("No native ExponentConstants module found, are you sure the expo-constants's module is linked properly?");const s=(0,t.requireOptionalNativeModule)('ExpoUpdates');let f=null;if(s){let e;s.manifest?e=s.manifest:s.manifestString&&(e=JSON.parse(s.manifestString)),e&&Object.keys(e).length>0&&(f=e)}let c=null;if(u.default.EXDevLauncher){let e;u.default.EXDevLauncher.manifestString&&(e=JSON.parse(u.default.EXDevLauncher.manifestString)),e&&Object.keys(e).length>0&&(c=e)}let p=null;if(o.default&&o.default.manifest){const e=o.default.manifest;p='string'==typeof e?JSON.parse(e):e}let b=f??c??p;const E=o.default||{},{appOwnership:O}=E,x=(0,n.default)(E,["name","appOwnership"]),v=Object.assign({},x,{appOwnership:O??null});function _(e){return!h(e)}function h(e){return'metadata'in e}function S(e=!1){if(!b){const e=null===b?'null':'undefined';if(x.executionEnvironment,l.ExecutionEnvironment.Bare,x.executionEnvironment===l.ExecutionEnvironment.StoreClient||x.executionEnvironment===l.ExecutionEnvironment.Standalone)throw new t.CodedError('ERR_CONSTANTS_MANIFEST_UNAVAILABLE',`Constants.manifest is ${e}, must be an object.`)}return b}Object.defineProperties(v,{__unsafeNoWarnManifest:{get(){const e=S(!0);return e&&_(e)?e:null},enumerable:!1},__unsafeNoWarnManifest2:{get(){const e=S(!0);return e&&h(e)?e:null},enumerable:!1},manifest:{get(){const e=S();return e&&_(e)?e:null},enumerable:!0},manifest2:{get(){const e=S();return e&&h(e)?e:null},enumerable:!0},expoConfig:{get(){const e=S(!0);return e?s&&s.isEmbeddedLaunch?p:h(e)?e.extra?.expoClient??null:_(e)?e:null:null},enumerable:!0},expoGoConfig:{get(){const e=S(!0);return e?h(e)?e.extra?.expoGo??null:_(e)?e:null:null},enumerable:!0},easConfig:{get(){const e=S(!0);return e?h(e)?e.extra?.eas??null:_(e)?e:null:null},enumerable:!0},__rawManifest_TEST:{get:()=>b,set(e){b=e},enumerable:!1}});var N=v},701,[35,4,25,393,702,703]);
|
|
824
824
|
__d(function(g,r,i,a,m,e,d){"use strict";var t,n,o;Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AppOwnership",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ExecutionEnvironment",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UserInterfaceIdiom",{enumerable:!0,get:function(){return o}}),(function(t){t.Expo="expo"})(t||(t={})),(function(t){t.Bare="bare",t.Standalone="standalone",t.StoreClient="storeClient"})(n||(n={})),(function(t){t.Handset="handset",t.Tablet="tablet",t.Desktop="desktop",t.TV="tv",t.Unsupported="unsupported"})(o||(o={}))},702,[]);
|
|
825
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var n=r(d[0]);const t=(Date.now()+'-'+Math.floor(1e9*Math.random())).toString();function o(){if('undefined'!=typeof navigator&&'string'==typeof navigator.userAgent){const n=navigator.userAgent.toLowerCase();if(n.includes('edge'))return'Edge';if(n.includes('edg'))return'Chromium Edge';if(n.includes('opr')&&'opr'in window&&window.opr)return'Opera';if(n.includes('chrome')&&'chrome'in window&&window.chrome)return'Chrome';if(n.includes('trident'))return'IE';if(n.includes('firefox'))return'Firefox';if(n.includes('safari'))return'Safari'}}var s={get appOwnership(){return null},get executionEnvironment(){return n.ExecutionEnvironment.Bare},get sessionId(){return t},get isHeadless(){return'undefined'==typeof navigator||/\bHeadlessChrome\//.test(navigator.userAgent)},get expoVersion(){return this.manifest.sdkVersion||null},get linkingUri(){return'undefined'!=typeof location?location.origin:''},get expoRuntimeVersion(){return this.expoVersion},get deviceName(){return o()},get systemFonts(){return[]},get statusBarHeight(){return 0},get deviceYearClass(){return null},get manifest(){return"{\"name\":\"Paseo\",\"slug\":\"voice-mobile\",\"version\":\"0.
|
|
825
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});var n=r(d[0]);const t=(Date.now()+'-'+Math.floor(1e9*Math.random())).toString();function o(){if('undefined'!=typeof navigator&&'string'==typeof navigator.userAgent){const n=navigator.userAgent.toLowerCase();if(n.includes('edge'))return'Edge';if(n.includes('edg'))return'Chromium Edge';if(n.includes('opr')&&'opr'in window&&window.opr)return'Opera';if(n.includes('chrome')&&'chrome'in window&&window.chrome)return'Chrome';if(n.includes('trident'))return'IE';if(n.includes('firefox'))return'Firefox';if(n.includes('safari'))return'Safari'}}var s={get appOwnership(){return null},get executionEnvironment(){return n.ExecutionEnvironment.Bare},get sessionId(){return t},get isHeadless(){return'undefined'==typeof navigator||/\bHeadlessChrome\//.test(navigator.userAgent)},get expoVersion(){return this.manifest.sdkVersion||null},get linkingUri(){return'undefined'!=typeof location?location.origin:''},get expoRuntimeVersion(){return this.expoVersion},get deviceName(){return o()},get systemFonts(){return[]},get statusBarHeight(){return 0},get deviceYearClass(){return null},get manifest(){return"{\"name\":\"Paseo\",\"slug\":\"voice-mobile\",\"version\":\"0.9.0\",\"orientation\":\"portrait\",\"icon\":\"./assets/images/icon.png\",\"scheme\":\"paseo\",\"userInterfaceStyle\":\"automatic\",\"newArchEnabled\":true,\"web\":{\"output\":\"single\",\"favicon\":\"./assets/images/favicon.png\",\"shortName\":\"Paseo\",\"orientation\":\"portrait\",\"name\":\"Paseo\"},\"autolinking\":{\"searchPaths\":[\"../../node_modules\",\"./node_modules\"]},\"experiments\":{\"typedRoutes\":true,\"reactCompiler\":true,\"autolinkingModuleResolution\":true},\"extra\":{\"fdroidBuild\":false,\"profileBuild\":false,\"router\":{},\"eas\":{\"projectId\":\"0e7f65ce-0367-46c8-a238-2b65963d235a\"}},\"owner\":\"getpaseo\",\"sdkVersion\":\"54.0.0\",\"platforms\":[\"ios\",\"android\",\"web\"]}"},get manifest2(){return null},get experienceUrl(){return'undefined'!=typeof location?location.origin:''},get debugMode(){return!1},getWebViewUserAgentAsync:async()=>'undefined'!=typeof navigator?navigator.userAgent:null}},703,[702]);
|
|
826
826
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SITEMAP_ROUTE_NAME=e.NOT_FOUND_ROUTE_NAME=e.INTERNAL_SLOT_NAME=void 0,e.INTERNAL_SLOT_NAME='__root',e.NOT_FOUND_ROUTE_NAME='+not-found',e.SITEMAP_ROUTE_NAME='_sitemap'},704,[]);
|
|
827
827
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.resolveHref=void 0,e.resolveHrefStringWithSegments=function(t,{segments:n=[],params:s={}}={},{relativeToDirectory:o}={}){if(t.startsWith('.')){let c=n?.map(t=>{if(!t.startsWith('['))return t;if(t.startsWith('[...')){t=t.slice(4,-1);const n=s[t];return Array.isArray(n)?n.join('/'):n?.split(',')?.join('/')??''}return t=t.slice(1,-1),s[t]}).filter(Boolean).join('/')??'/';o&&(c=`${c}/`);const f=new URL(t,`http://hostname/${c}`);t=`${f.pathname}${f.search}`}return t};function t(t,s){for(const[o,c=""]of Object.entries(s)){const f=`[${o}]`,l=`[...${o}]`;if(t.includes(f))t=t.replace(f,n(c));else{if(!t.includes(l))continue;t=t.replace(l,n(c))}delete s[o]}return{pathname:t,params:s}}function n(t){return Array.isArray(t)?t.map(t=>n(t)).join('/'):encodeURIComponent(t.toString())}function s(t){return Object.entries(t).filter(([,t])=>null!=t).map(([t,n])=>`${t}=${encodeURIComponent(n.toString())}`).join('&')}e.resolveHref=n=>{if('string'==typeof n)return(0,e.resolveHref)({pathname:n});const o=n.pathname??'';if(!n?.params)return o;const{pathname:c,params:f}=t(o,Object.assign({},n.params)),l=s(f);return c+(l?`?${l}`:'')}},705,[]);
|
|
828
828
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isRoutePreloadedInStack=function(t,o){if(!t||'stack'!==t.type)return!1;return t.preloadedRoutes.some(t=>t.key===o.key)}},706,[]);
|
|
@@ -15106,7 +15106,7 @@ __d(function(g,r,i,_a,m,e,d){'use strict';const t=r(d[0]);m.exports=(s,c,n)=>t(s
|
|
|
15106
15106
|
__d(function(g,r,i,_a,m,e,d){'use strict';const t=r(d[0]);m.exports=(s,c,n)=>t(s,c,n)<=0},3461,[3456]);
|
|
15107
15107
|
__d(function(g,r,i,a,m,e,d){'use strict';const t=r(d[0]);m.exports=(n,c,s)=>{try{c=new t(c,s)}catch(t){return!1}return c.test(n)}},3462,[3451]);
|
|
15108
15108
|
__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.resolveAppVersion=function(){const e=u(t.default?.version);if(e)return e;const o=u(n.default.expoConfig?.version);if(o)return o;const f=u(n.default.manifest?.version);if(f)return f;return null};var n=e(r(d[0])),t=e(r(d[1]));function u(e){if("string"!=typeof e)return null;const n=e.trim();return 0===n.length?null:n}},3463,[701,3464]);
|
|
15109
|
-
__d(function(e,t,r,o,a,i,n){a.exports={name:"@getpaseo/app",version:"0.9.0-beta.
|
|
15109
|
+
__d(function(e,t,r,o,a,i,n){a.exports={name:"@getpaseo/app",version:"0.9.0-beta.2",private:!0,main:"index.ts",scripts:{start:"npm run start:expo","start:expo":"cross-env APP_VARIANT=development expo start","reset-project":"node ./scripts/reset-project.js","eas-build-post-install":"npm --prefix ../.. run build:app-deps && npm run build:terminal-webview",android:"npm run android:development","android:development":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=development expo prebuild --platform android --clean --non-interactive && cross-env APP_VARIANT=development expo run:android --variant=debug","android:production":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=production expo prebuild --platform android --clean --non-interactive && cross-env APP_VARIANT=production expo run:android --variant=release","android:release":"npm run android:production","android:clear":"node -e \"require('node:fs').rmSync('android', { recursive: true, force: true })\"",ios:"npm --prefix ../.. run build:client && expo run:ios","ios:release":"npm --prefix ../.. run build:client && expo run:ios --configuration Release",web:"npm --prefix ../.. run build:client && concurrently --kill-others --names protocol,client,expo --prefix-colors yellow,blue,magenta \"npm --prefix ../.. run watch:protocol\" \"npm --prefix ../.. run watch:client\" \"npm run web:expo\"","web:expo":"expo start --web",lint:"expo lint",typecheck:"tsgo --noEmit",test:"vitest run","test:browser":"vitest run --project browser","test:e2e":"playwright test --project=browser","test:e2e:diff-performance":"cross-env PASEO_DIFF_PERF_E2E=1 playwright test --project=browser e2e/browser/diff-performance.spec.ts","test:e2e:stream-smoothness":"cross-env PASEO_AGENT_STREAM_PERF_E2E=1 playwright test --project=browser e2e/browser/agent-stream-smoothness.spec.ts","test:e2e:real":"cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=real-provider","test:e2e:relay-deployment":"npm --prefix ../.. run build:server && npm --prefix ../.. run build:daemon-web-ui && cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=relay-deployment e2e/browser/relay-deployment-reconnect.real.spec.ts","test:e2e:ui":"playwright test --ui",build:"npm run build:web","build:web":"npm --prefix ../.. run build:app-deps && expo export --platform web","profile:composer-typing":"node ./scripts/profile-composer-typing.mjs","profile:explorer-toggle":"node ./scripts/profile-explorer-toggle.mjs","profile:side-pane":"playwright test --config playwright.profile.config.ts side-pane-performance.spec.ts","profile:workspace-switching":"node ./scripts/profile-workspace-switching.mjs","profile:workspace-tabs":"node ./scripts/profile-workspace-tabs.mjs","deploy:web":"npm run build:web && wrangler pages deploy dist --project-name paseo-app --branch main","build:terminal-webview":"node ./scripts/build-terminal-webview-html.mjs","build:mermaid-runtime":"node ./src/components/markdown/fence/mermaid/build-runtime.mjs"},dependencies:{"@codemirror/commands":"6.10.4","@codemirror/language":"6.12.4","@codemirror/search":"6.7.1","@codemirror/state":"6.7.1","@codemirror/view":"6.43.6","@dnd-kit/core":"^6.3.1","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@floating-ui/react-native":"^0.10.7","@getpaseo/client":"*","@getpaseo/expo-two-way-audio":"*","@getpaseo/highlight":"*","@getpaseo/plugin":"*","@getpaseo/protocol":"*","@gorhom/bottom-sheet":"^5.2.14","@gorhom/portal":"^1.0.14","@marijn/find-cluster-break":"^1.0.2","@mattermost/react-native-paste-input":"2.0.1","@react-native-async-storage/async-storage":"2.2.0","@react-native-masked-view/masked-view":"^0.3.2","@react-native/normalize-colors":"^0.81.5","@react-navigation/native":"^7.1.8","@replit/codemirror-vim":"6.3.0","@shopify/react-native-skia":"2.2.12","@tanstack/react-query":"^5.90.11","@tanstack/react-virtual":"^3.13.21","@xterm/addon-clipboard":"^0.3.0-beta.213","@xterm/addon-fit":"^0.12.0-beta.213","@xterm/addon-image":"^0.10.0-beta.213","@xterm/addon-ligatures":"^0.11.0-beta.213","@xterm/addon-search":"^0.17.0-beta.213","@xterm/addon-unicode11":"^0.10.0-beta.213","@xterm/addon-web-links":"^0.13.0-beta.213","@xterm/addon-webgl":"^0.20.0-beta.212","@xterm/xterm":"^6.1.0-beta.213",buffer:"^6.0.3",expo:"^54.0.18","expo-asset":"~12.0.12","expo-audio":"~1.0.13","expo-build-properties":"^1.0.9","expo-camera":"~17.0.10","expo-clipboard":"~8.0.7","expo-constants":"~18.0.9","expo-crypto":"^15.0.8","expo-dev-client":"^6.0.15","expo-document-picker":"~14.0.8","expo-file-system":"~19.0.17","expo-haptics":"~15.0.7","expo-image":"~3.0.10","expo-image-manipulator":"~14.0.8","expo-image-picker":"^17.0.8","expo-keep-awake":"^15.0.7","expo-linking":"~8.0.8","expo-localization":"~17.0.9","expo-notifications":"^0.32.16","expo-router":"~6.0.13","expo-sharing":"^14.0.8","expo-splash-screen":"~31.0.10","expo-sqlite":"~16.0.10","expo-system-ui":"~6.0.7","fast-deep-equal":"^3.1.3",htmlparser2:"^12.0.0",i18next:"^26.3.0","lucide-react-native":"^0.546.0","markdown-it":"^10.0.0",mermaid:"^11.16.0","mnemonic-id":"^3.2.7",qrcode:"^1.5.4",react:"19.1.0","react-dom":"19.1.0","react-freeze":"1.0.4","react-i18next":"^17.0.8","react-native":"0.81.5","react-native-draggable-flatlist":"^4.0.3","react-native-edge-to-edge":"^1.7.0","react-native-gesture-handler":"~2.28.0","react-native-keyboard-controller":"1.21.12","react-native-markdown-display":"^7.0.2","react-native-nitro-modules":"0.35.5","react-native-reanimated":"~4.3.1","react-native-safe-area-context":"~5.6.0","react-native-screens":"~4.16.0","react-native-svg":"^15.14.0","react-native-uitextview":"^2.2.0","react-native-unistyles":"^3.2.4","react-native-web":"~0.21.0","react-native-webview":"^13.16.0","react-native-worklets":"~0.8.3","tiny-invariant":"^1.3.3",turndown:"^7.2.4","turndown-plugin-gfm":"^1.0.2","use-sync-external-store":"^1.6.0",yaml:"^2.8.4",zod:"^4.4.3",zustand:"^5.0.9"},devDependencies:{"@playwright/test":"^1.56.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2","@types/markdown-it":"^14.1.2","@types/node":"~22.19.0","@types/qrcode":"^1.5.6","@types/react":"~19.2.0","@types/turndown":"^5.0.6","@types/ws":"^8.18.1","@vitest/browser":"^4.1.7","@vitest/browser-playwright":"^4.1.7","@xterm/headless":"^6.1.0-beta.213",dotenv:"^17.2.3","eas-cli":"^16.24.1",esbuild:"0.28.1",eslint:"^9.25.0","eslint-config-expo":"~10.0.0","expo-gradle-jvmargs":"^1.1.2","fake-indexeddb":"^6.2.5",jsdom:"^20.0.3","material-icon-theme":"^5.32.0",playwright:"^1.56.1","serve-sim":"^0.1.40",typescript:"~5.9.2",vitest:"^4.1.6",wrangler:"^4.105.0",ws:"^8.20.0"},reanimated:{staticFeatureFlags:{FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS:!1}}}},3464,[]);
|
|
15110
15110
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createPluginClientRuntime=function(P,I){const v=(0,c.createPluginSurfaceRuntime)(I,P);if(!v)throw new Error("Plugin host is offline");const f=(0,l.createPluginClientStateSource)(P.serverId),w=(0,o.createPluginCapabilities)(P,v,(0,s.createPluginNavigation)({serverId:P.serverId,workspaceId:null}));return Object.assign({},w,{hosts:(0,n.createPluginHosts)((0,t.getHostRuntimeStore)(),P.lifetime.signal),addComposerPill:t=>u.pluginButtonStore.addComposerPill(P,t),addHeaderButton:t=>u.pluginButtonStore.addHeaderButton(P,t),openPanel(t,n){p({installation:P,runtime:v,state:f,panelId:t,options:n})}})};var t=r(d[0]),n=r(d[1]),o=r(d[2]),l=r(d[3]),s=r(d[4]),u=r(d[5]),c=r(d[6]);function p(t){const{installation:n,runtime:l,state:u,panelId:c,options:p}=t,P=p.workspaceId.trim(),I=p.agentId?.trim(),v=(0,s.createPluginNavigation)({serverId:n.serverId,workspaceId:P}),f=I?(0,o.createPluginAgentActionContext)({plugin:n,runtime:l,navigation:v,state:u,workspaceId:P,agentId:I}):(0,o.createPluginWorkspaceActionContext)({plugin:n,runtime:l,navigation:v,state:u,workspaceId:P});if(!f)throw new Error("Plugin panel context is unavailable");f.openPanel(c,{location:p.location})}},3465,[3466,3635,3638,3647,3652,3664,3669]);
|
|
15111
15111
|
__d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.isHostRuntimeConnected=Q,_e.isHostRuntimeDirectoryLoading=K,Object.defineProperty(_e,"HostRuntimeController",{enumerable:!0,get:function(){return ae}}),_e.readInitialDaemonConnectionHint=ye,_e.hasConfiguredLocalDaemonOverride=function(){return null!==ge()},Object.defineProperty(_e,"HostRuntimeStore",{enumerable:!0,get:function(){return Ce}}),_e.getHostRuntimeStore=Ie,_e.getHostRuntimeConnectionStatusSince=function(e){return Ie().getConnectionStatusSince(e)},_e.useHostRuntimeSnapshot=function(e){const s=(0,t.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]!==e?(l=t=>c.subscribe(e,t),h=()=>c.getSnapshot(e),u=()=>c.getSnapshot(e),s[1]=e,s[2]=l,s[3]=h,s[4]=u):(l=s[2],h=s[3],u=s[4]);return(0,n.useSyncExternalStore)(l,h,u)},_e.useHostRuntimeClient=function(e){const s=(0,t.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]!==e?(l=t=>c.subscribe(e,t),h=()=>c.getSnapshot(e)?.client??null,u=()=>c.getSnapshot(e)?.client??null,s[1]=e,s[2]=l,s[3]=h,s[4]=u):(l=s[2],h=s[3],u=s[4]);return(0,n.useSyncExternalStore)(l,h,u)},_e.useHostRuntimeIsConnected=function(e){const s=(0,t.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]!==e?(l=t=>c.subscribe(e,t),h=()=>Q(c.getSnapshot(e)),u=()=>Q(c.getSnapshot(e)),s[1]=e,s[2]=l,s[3]=h,s[4]=u):(l=s[2],h=s[3],u=s[4]);return(0,n.useSyncExternalStore)(l,h,u)},_e.useHostRuntimeConnectionStatus=function(e){const s=(0,t.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]!==e?(l=t=>c.subscribe(e,t),h=()=>c.getSnapshot(e)?.connectionStatus??"connecting",u=()=>c.getSnapshot(e)?.connectionStatus??"connecting",s[1]=e,s[2]=l,s[3]=h,s[4]=u):(l=s[2],h=s[3],u=s[4]);return(0,n.useSyncExternalStore)(l,h,u)},_e.useHostRuntimeConnectionStatuses=function(e){const s=(0,t.c)(7);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]===Symbol.for("react.memo_cache_sentinel")?(l=e=>c.subscribeAll(e),h=()=>c.getVersion(),u=()=>c.getVersion(),s[1]=l,s[2]=h,s[3]=u):(l=s[1],h=s[2],u=s[3]);(0,n.useSyncExternalStore)(l,h,u);let p;if(s[4]!==e){let t;s[6]===Symbol.for("react.memo_cache_sentinel")?(t=e=>[e,c.getSnapshot(e)?.connectionStatus??"connecting"],s[6]=t):t=s[6];const n=e.map(t);p=new Map(n),s[4]=e,s[5]=p}else p=s[5];return p},_e.useHostRuntimeLastError=function(e){const s=(0,t.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]!==e?(l=t=>c.subscribe(e,t),h=()=>c.getSnapshot(e)?.lastError??null,u=()=>c.getSnapshot(e)?.lastError??null,s[1]=e,s[2]=l,s[3]=h,s[4]=u):(l=s[2],h=s[3],u=s[4]);return(0,n.useSyncExternalStore)(l,h,u)},_e.useHostRuntimeAgentDirectoryStatus=function(e){const s=(0,t.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]!==e?(l=t=>c.subscribe(e,t),h=()=>c.getSnapshot(e)?.agentDirectoryStatus??"idle",u=()=>c.getSnapshot(e)?.agentDirectoryStatus??"idle",s[1]=e,s[2]=l,s[3]=h,s[4]=u):(l=s[2],h=s[3],u=s[4]);return(0,n.useSyncExternalStore)(l,h,u)},_e.useHostRuntimeIsDirectoryLoading=function(e){const s=(0,t.c)(5);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=Ie(),s[0]=o):o=s[0];const c=o;let l,h,u;s[1]!==e?(l=t=>c.subscribe(e,t),h=()=>K(c.getSnapshot(e)),u=()=>K(c.getSnapshot(e)),s[1]=e,s[2]=l,s[3]=h,s[4]=u):(l=s[2],h=s[3],u=s[4]);return(0,n.useSyncExternalStore)(l,h,u)},_e.useHosts=function(){const e=(0,t.c)(4);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Ie(),e[0]=s):s=e[0];const o=s;let c,l,h;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=e=>o.subscribeHostList(e),l=()=>o.getHosts(),h=()=>o.getHosts(),e[1]=c,e[2]=l,e[3]=h):(c=e[1],l=e[2],h=e[3]);return(0,n.useSyncExternalStore)(c,l,h)},_e.useHostRegistryStatus=function(){const e=(0,t.c)(4);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Ie(),e[0]=s):s=e[0];const o=s;let c,l,h;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=e=>o.subscribeHostList(e),l=()=>o.getHostRegistryStatus(),h=()=>o.getHostRegistryStatus(),e[1]=c,e[2]=l,e[3]=h):(c=e[1],l=e[2],h=e[3]);return(0,n.useSyncExternalStore)(c,l,h)},_e.useHostRegistryLoaded=function(){const e=(0,t.c)(4);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Ie(),e[0]=s):s=e[0];const o=s;let c,l,h;e[1]===Symbol.for("react.memo_cache_sentinel")?(c=e=>o.subscribeHostList(e),l=()=>o.isHostRegistryLoaded(),h=()=>o.isHostRegistryLoaded(),e[1]=c,e[2]=l,e[3]=h):(c=e[1],l=e[2],h=e[3]);return(0,n.useSyncExternalStore)(c,l,h)},_e.useHostMutations=function(){const e=(0,t.c)(2);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Ie(),e[0]=n):n=e[0];const s=n;let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={upsertDirectConnection:e=>s.upsertDirectConnection(e),probeAndUpsertDirectConnection:e=>s.probeAndUpsertDirectConnection(e),probeAndUpsertRemoteSshConnection:e=>s.probeAndUpsertRemoteSshConnection(e),upsertRelayConnection:e=>s.upsertRelayConnection(e),upsertConnectionFromOffer:(e,t)=>s.upsertConnectionFromOffer(e,t),upsertConnectionFromOfferUrl:(e,t)=>s.upsertConnectionFromOfferUrl(e,t),renameHost:(e,t)=>s.renameHost(e,t),setHostColor:(e,t)=>s.setHostColor(e,t),setHostBadgeDisplay:(e,t)=>s.setHostBadgeDisplay(e,t),removeHost:e=>s.removeHost(e),removeConnection:(e,t)=>s.removeConnection(e,t)},e[1]=o):o=e[1];return o};var t=r(d[0]),n=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),c=r(d[4]),l=r(d[5]),h=r(d[6]),u=r(d[7]),p=r(d[8]),y=r(d[9]),S=r(d[10]),v=r(d[11]),f=r(d[12]),C=r(d[13]),b=r(d[14]),I=r(d[15]),w=r(d[16]),A=r(d[17]),H=r(d[18]),R=r(d[19]),D=r(d[20]),E=r(d[21]),P=r(d[22]),O=r(d[23]),L=r(d[24]),_=r(d[25]),T=r(d[26]),M=r(d[27]),B=r(d[28]),k=r(d[29]),F=r(d[30]),q=r(d[31]),j=r(d[32]),x=r(d[33]),U=r(d[34]),V=r(d[35]),W=r(d[36]),N=r(d[37]),$=r(d[38]),G=r(d[39]);function z(e,t,n){e[t]=n}function Q(e){return"online"===e?.connectionStatus}function K(e){return!e||("initial_loading"===e.agentDirectoryStatus||"revalidating"===e.agentDirectoryStatus||!e.hasEverLoadedAgentDirectory&&("connecting"===e.connectionStatus||"online"===e.connectionStatus))}function J(e){return e instanceof Error?e.message:String(e)}function X(e){let t=0;for(let n=0;n<e.length;n+=1)t=31*t+e.charCodeAt(n)|0;return`h_${Math.abs(t).toString(16)}`}function Y(e){return"directSocket"===e.type?{type:"directSocket",endpoint:e.path,display:"socket"}:"directPipe"===e.type?{type:"directPipe",endpoint:e.path,display:"pipe"}:"remoteSsh"===e.type?{type:"remoteSsh",endpoint:e.host,display:e.host}:"directTcp"===e.type?{type:"directTcp",endpoint:e.endpoint,display:e.endpoint}:{type:"relay",endpoint:e.relayEndpoint,display:"relay"}}function Z(e){return"connecting"===e.tag||"online"===e.tag||"offline"===e.tag||"error"===e.tag?{id:e.activeConnectionId,connection:e.activeConnection}:{id:null,connection:null}}function ee(e,t,n){const s=n.state.status;return"connected"===s?{tag:"online",activeConnectionId:e,activeConnection:t,lastOnlineAt:(new Date).toISOString()}:"connecting"===s||"idle"===s?{tag:"connecting",activeConnectionId:e,activeConnection:t}:"disposed"===s?{tag:"offline",activeConnectionId:e,activeConnection:t}:null}function te(e,t,n){const s=ee(e,t,n);if(s)return s;const o=("disconnected"===n.state.status?n.state.reason??null:null)??n.lastError??null;return o&&"client_closed"!==o?{tag:"error",activeConnectionId:e,activeConnection:t,message:o}:{tag:"offline",activeConnectionId:e,activeConnection:t}}function ne(e){const{state:t,event:n}=e;if("select_connection"===n.type)return{tag:"connecting",activeConnectionId:n.connectionId,activeConnection:n.connection};if("connect_failed"===n.type){const e=Z(t);return{tag:"error",activeConnectionId:e.id,activeConnection:e.connection,message:n.message}}if("no_connections"===n.type||"stopped"===n.type)return{tag:"offline",activeConnectionId:null,activeConnection:null};const s=Z(t);return s.id&&s.connection?te(s.id,s.connection,n):"booting"===t.tag?t:{tag:"offline",activeConnectionId:null,activeConnection:null}}function se(e,t){return"booting"===e.tag?{activeConnectionId:null,activeConnection:null,connectionStatus:"connecting",lastError:null,lastOnlineAt:null,connectionEpoch:t}:"connecting"===e.tag?{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"connecting",lastError:null,lastOnlineAt:null,connectionEpoch:t}:"online"===e.tag?{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"online",lastError:null,lastOnlineAt:e.lastOnlineAt,connectionEpoch:t}:"offline"===e.tag?{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"offline",lastError:null,lastOnlineAt:null,connectionEpoch:t}:{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"error",lastError:e.message,lastOnlineAt:null,connectionEpoch:t}}function ie(e){return e.connections.map(e=>({connectionId:e.id,connection:e}))}function oe(e,t){return t?e.connections.find(e=>e.id===t)??null:null}function re(e,t,n,s){if(t)return 1e4;if(n)return 12e4;const o=s-e;return o<1e4?2e3:o<3e4?5e3:o<6e4?1e4:3e4}function ce(){const e="function"==typeof(0,H.getDesktopHost)()?.browser?.executeAutomationCommand?{[R.CLIENT_CAPS.browserHost]:{supportedCommands:[...D.BROWSER_AUTOMATION_COMMAND_NAMES],hostKind:"desktop app"}}:void 0,t=Object.assign({},e);return{createClient:({host:e,connection:n,clientId:s,runtimeGeneration:o})=>{const l=(0,A.createDesktopDaemonTransportFactory)(),h={webSocketFactory:(0,G.createAppWebSocketFactory)()},y={suppressSendErrors:!0,clientId:s,clientType:"mobile",appVersion:(0,p.resolveAppVersion)()??void 0,runtimeGeneration:o,capabilities:t,trace:N.nativePerformanceTrace,providerSnapshots:"wire"};if("directSocket"===n.type||"directPipe"===n.type)return new c.DaemonClient(Object.assign({},y,l?{transportFactory:l}:{},{url:(0,A.buildDesktopDaemonTransportUrl)({transportType:"directSocket"===n.type?"socket":"pipe",transportPath:n.path})}));if("remoteSsh"===n.type){if(!l)throw new Error("Remote SSH is only available in the desktop app.");return new c.DaemonClient(Object.assign({},y,{transportFactory:l,url:(0,A.buildDesktopDaemonTransportUrl)(Object.assign({transportType:"ssh",host:n.host},void 0!==n.sshPort?{sshPort:n.sshPort}:{},void 0!==n.daemonPort?{daemonPort:n.daemonPort}:{}))}))}return"directTcp"===n.type?new c.DaemonClient(Object.assign({},y,h,{url:(0,u.buildDaemonWebSocketUrl)(n.endpoint,{useTls:n.useTls??!1})},n.password?{password:n.password}:{})):new c.DaemonClient(Object.assign({},y,h,{url:(0,u.buildRelayWebSocketUrl)({endpoint:n.relayEndpoint,useTls:n.useTls??(0,u.shouldUseTlsForDefaultHostedRelay)(n.relayEndpoint),serverId:e.serverId}),e2ee:{enabled:!0,daemonPublicKeyB64:n.daemonPublicKeyB64}}))},connectToDaemon:({host:e,connection:n,timeoutMs:s})=>(0,f.connectToDaemon)(n,Object.assign({},e.serverId?{serverId:e.serverId}:{},void 0!==s?{timeoutMs:s}:{},{capabilities:t,trace:N.nativePerformanceTrace})),getClientId:()=>(0,C.getOrCreateClientId)(),mountClientHandlers:({client:t,host:n})=>{const s=(0,_.mountServerDataPushRouter)({client:t,queryClient:L.queryClient,serverId:n.serverId});if(!e)return s;const o=(0,T.mountBrowserAutomationDaemonClientHandler)(t,{serverId:n.serverId});return()=>{o(),s()}}}}class ae{connectionEpoch=0;listeners=new Set;activeClient=null;unsubscribeClientStatus=null;unsubscribeClientHandlers=null;probeIntervalHandle=null;started=!1;connectionFirstSeenAt=new Map;connectionLastProbedAt=new Map;switchCandidateConnectionId=null;switchCandidateHitCount=0;clientIdPromise=null;clientIdHash=null;switchRequestVersion=0;probeRequestVersion=0;probeCycleInFlight=null;constructor(e){this.host=e.host,this.deps=e.deps??ce(),this.onReconcileServerId=e.onReconcileServerId??null,this.connectionMachineState={tag:"booting"},this.snapshot=Object.assign({serverId:this.host.serverId},se(this.connectionMachineState,this.connectionEpoch),{client:null,agentDirectoryStatus:"idle",agentDirectoryError:null,hasEverLoadedAgentDirectory:!1,probeByConnectionId:new Map,clientGeneration:0})}getSnapshot(){return this.snapshot}getClient(){return this.snapshot.client}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async start(e){this.started||(this.started=!0,this.trackConnectionFirstSeen(),e?.initialConnection&&await this.switchToConnection({connectionId:e.initialConnection.connectionId,existingClient:e.initialConnection.existingClient}),await this.runProbeCycleNow(),!1!==e?.autoProbe&&(this.probeIntervalHandle=setInterval(()=>{this.runProbeCycleNow()},2e3)))}async stop(){if(this.switchRequestVersion+=1,this.probeRequestVersion+=1,this.started=!1,this.probeIntervalHandle&&(clearInterval(this.probeIntervalHandle),this.probeIntervalHandle=null),this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const e=this.activeClient;this.activeClient=null,await e.close().catch(()=>{})}this.applyConnectionEvent({type:"stopped"}),this.updateSnapshot(Object.assign({},se(this.connectionMachineState,this.connectionEpoch),{client:null}))}async updateHost(e){const t=this.snapshot.activeConnectionId,n=oe(this.host,t);this.host=e,this.trackConnectionFirstSeen();const s=oe(this.host,t);t&&n&&s&&!(0,o.default)(n,s)&&(this.connectionLastProbedAt.delete(t),await this.switchToConnection({connectionId:t})),await this.runProbeCycleNow()}ensureConnected(e){this.activeClient?.ensureConnected(e)}markAgentDirectorySyncLoading(){const e=this.snapshot.hasEverLoadedAgentDirectory?"revalidating":"initial_loading";this.updateSnapshot({agentDirectoryStatus:e,agentDirectoryError:null})}markAgentDirectorySyncReady(){this.updateSnapshot({agentDirectoryStatus:"ready",agentDirectoryError:null,hasEverLoadedAgentDirectory:!0})}markAgentDirectorySyncError(e){const t=this.snapshot.hasEverLoadedAgentDirectory;this.updateSnapshot({agentDirectoryStatus:t?"error_after_ready":"error_before_first_success",agentDirectoryError:e,hasEverLoadedAgentDirectory:t})}markAgentDirectorySyncIdle(){this.updateSnapshot({agentDirectoryStatus:this.snapshot.hasEverLoadedAgentDirectory?"ready":"idle",agentDirectoryError:null})}markStartupError(e){this.applyConnectionEvent({type:"connect_failed",message:e}),this.updateSnapshot(Object.assign({},se(this.connectionMachineState,this.connectionEpoch)))}async activateConnection(e){await this.switchToConnection(e)}async runProbeCycleNow(){if(this.probeCycleInFlight)return this.probeCycleInFlight;const e=this.runProbeCycle().finally(()=>{this.probeCycleInFlight===e&&(this.probeCycleInFlight=null)});return this.probeCycleInFlight=e,e}async runProbeCycle(){const e=++this.probeRequestVersion;if(0===this.host.connections.length){if(!this.isCurrentProbeRequest(e))return;return this.applyConnectionEvent({type:"no_connections"}),void this.updateSnapshot(Object.assign({},se(this.connectionMachineState,this.connectionEpoch),{probeByConnectionId:new Map}))}const t=performance.now(),n="online"===this.snapshot.connectionStatus,s=this.snapshot.activeConnectionId,o=n&&null!==s,c=this.host.connections.filter(e=>{const c=this.connectionLastProbedAt.get(e.id);if(null==c)return!0;const l=re(this.connectionFirstSeenAt.get(e.id)??t,n&&e.id===s,o,t);return t-c>=l});if(0===c.length)return;const l=new Map(this.snapshot.probeByConnectionId);for(const e of c){this.connectionLastProbedAt.set(e.id,performance.now());const t=l.get(e.id);n&&e.id===s&&"available"===t?.status||l.set(e.id,{status:"pending",latencyMs:null})}this.updateSnapshot({probeByConnectionId:new Map(l)});let h=c.length,u=null;const p=()=>{this.isCurrentProbeRequest(e)&&this.updateSnapshot({probeByConnectionId:new Map(l)})},y=async(t,n)=>{for(;!this.snapshot.activeConnectionId;){if(!u)return u=this.switchToConnection({connectionId:t,expectedProbeVersion:e,existingClient:n}).finally(()=>{u=null}),await u,this.snapshot.activeConnectionId===t;await u}return!1},S=async()=>{if(h>0||!this.isCurrentProbeRequest(e))return;const t=this.snapshot.activeConnectionId,n=t?l.get(t):null;if(!t||!oe(this.host,t)){const t=(0,w.selectBestConnection)({candidates:ie(this.host),probeByConnectionId:l});return void(t&&await this.switchToConnection({connectionId:t,expectedProbeVersion:e}))}if("unavailable"===n?.status){const n=(0,w.selectBestConnection)({candidates:ie(this.host),probeByConnectionId:l});return n&&n!==t&&await this.switchToConnection({connectionId:n,expectedProbeVersion:e}),this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0)}if(!n||"available"!==n.status)return;const s=Array.from(l.entries()).filter(e=>"available"===e[1].status).map(([e,t])=>({connectionId:e,latencyMs:t.latencyMs})).sort((e,t)=>e.latencyMs-t.latencyMs)[0]??null;if(!s||s.connectionId===t)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);if(n.latencyMs-s.latencyMs<40)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);this.switchCandidateConnectionId===s.connectionId?this.switchCandidateHitCount+=1:(this.switchCandidateConnectionId=s.connectionId,this.switchCandidateHitCount=1),this.switchCandidateHitCount>=3&&(this.switchCandidateConnectionId=null,this.switchCandidateHitCount=0,await this.switchToConnection({connectionId:s.connectionId,expectedProbeVersion:e}))};await new Promise(t=>{for(const n of c)(async()=>{let s=null,o=!1;try{const t=this.snapshot.activeConnectionId===n.id?this.snapshot.client:null;if(t)s=t;else{const{client:e,serverId:t}=await this.deps.connectToDaemon({host:this.host,connection:n});if(t!==this.host.serverId){if(!Se(this.host.serverId)||!this.onReconcileServerId)throw await e.close().catch(()=>{}),new Error(`Connection resolved to ${t}, expected ${this.host.serverId}.`);this.onReconcileServerId(this.host.serverId,t)}s=e,o=!0}if(!this.isCurrentProbeRequest(e))return;const c=await y(n.id,s);if(o=o&&!c,t){const s=t.getLastLivenessRttMs();if(!this.isCurrentProbeRequest(e))return;return void(null!==s&&(l.set(n.id,{status:"available",latencyMs:s}),p()))}const h=await s.measureLatency({timeoutMs:5e3});if(!this.isCurrentProbeRequest(e))return;l.set(n.id,{status:"available",latencyMs:h}),p()}catch{this.isCurrentProbeRequest(e)&&(l.set(n.id,{status:"unavailable",latencyMs:null}),p())}finally{s&&o&&await s.close().catch(()=>{}),h-=1,S().finally(()=>{0===h&&t()})}})()})}updateSnapshot(e){const t=Object.assign({},e);let n=this.host.serverId!==this.snapshot.serverId;for(const s of Object.keys(e)){const c=e[s];(0,o.default)(this.snapshot[s],c)?z(t,s,this.snapshot[s]):n=!0}if(n){this.snapshot=Object.assign({},this.snapshot,t,{serverId:this.host.serverId});for(const e of this.listeners)e()}}applyConnectionEvent(e){const t=this.connectionMachineState,n=ne({state:t,event:e});"online"!==t.tag&&"online"===n.tag&&(this.connectionEpoch+=1),this.connectionMachineState=n,this.logConnectionTransition({from:t.tag,to:n.tag,event:e})}logConnectionTransition(e){}trackConnectionFirstSeen(){const e=performance.now(),t=new Set(this.host.connections.map(e=>e.id));for(const e of this.connectionFirstSeenAt.keys())t.has(e)||(this.connectionFirstSeenAt.delete(e),this.connectionLastProbedAt.delete(e));for(const t of this.host.connections)this.connectionFirstSeenAt.has(t.id)||this.connectionFirstSeenAt.set(t.id,e)}isCurrentSwitchRequest(e){return e===this.switchRequestVersion}isCurrentProbeRequest(e){return e===this.probeRequestVersion}canProceedForProbe(e){return void 0===e||this.isCurrentProbeRequest(e)}async abortSwitchWithClient(e){e&&await e.close().catch(()=>{})}isSwitchStillValid(e,t){return this.isCurrentSwitchRequest(e)&&this.canProceedForProbe(t)}async resolveClientIdForSwitch(e){try{return await this.resolveClientId()}catch(t){if(await this.abortSwitchWithClient(e.existingClient),!this.isCurrentSwitchRequest(e.requestVersion))return null;const n=J(t);return this.applyConnectionEvent({type:"connect_failed",message:`Failed to resolve client id: ${n}`}),this.updateSnapshot(Object.assign({},se(this.connectionMachineState,this.connectionEpoch))),null}}async disposePreviousActiveClient(){if(this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const e=this.activeClient;this.activeClient=null,await e.close().catch(()=>{})}}buildAgentDirectoryStatusPatch(){if(this.snapshot.hasEverLoadedAgentDirectory)return{};const e=this.connectionMachineState.tag;return"connecting"===e||"online"===e?{agentDirectoryStatus:"initial_loading",agentDirectoryError:null}:"error"===e?{agentDirectoryStatus:"error_before_first_success",agentDirectoryError:this.connectionMachineState.message}:{agentDirectoryStatus:"idle",agentDirectoryError:null}}async switchToConnection(e){const{connectionId:t,expectedProbeVersion:n,existingClient:s}=e;if(!this.canProceedForProbe(n))return void await this.abortSwitchWithClient(s);const o=oe(this.host,t);if(!o)return void await this.abortSwitchWithClient(s);const c=++this.switchRequestVersion,l=await this.resolveClientIdForSwitch({existingClient:s,requestVersion:c});if(null===l)return;if(!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);if(await this.disposePreviousActiveClient(),!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);const h=this.snapshot.clientGeneration+1,u=s??this.deps.createClient({host:this.host,connection:o,clientId:l,runtimeGeneration:h});if(u.setReconnectEnabled(!0),!this.isSwitchStillValid(c,n))return void await u.close().catch(()=>{});this.activeClient=u,this.applyConnectionEvent({type:"select_connection",connectionId:o.id,connection:Y(o)}),this.snapshot=Object.assign({},this.snapshot,{clientGeneration:h}),this.updateSnapshot(Object.assign({},se(this.connectionMachineState,this.connectionEpoch),{client:null}));const p=async e=>{if(this.isCurrentSwitchRequest(c)&&this.activeClient===u){this.unsubscribeClientStatus?.(),this.unsubscribeClientStatus=null,this.unsubscribeClientHandlers?.(),this.unsubscribeClientHandlers=null,u.setReconnectEnabled(!1),this.applyConnectionEvent({type:"connect_failed",message:J(e)}),this.updateSnapshot(Object.assign({},se(this.connectionMachineState,this.connectionEpoch),{client:null}));try{await u.close()}catch{}}};try{if(s||await u.connect(),!this.isCurrentSwitchRequest(c)||this.activeClient!==u)return;this.unsubscribeClientHandlers=this.deps.mountClientHandlers?.({client:u,host:this.host,connection:o})??null,this.unsubscribeClientStatus=u.subscribeConnectionStatus(e=>{this.isCurrentSwitchRequest(c)&&this.activeClient===u&&(this.applyConnectionEvent({type:"client_state",state:e,lastError:u.lastError}),this.updateSnapshot(Object.assign({},se(this.connectionMachineState,this.connectionEpoch),this.buildAgentDirectoryStatusPatch(),{client:u})))})}catch(e){await p(e)}}adoptReconciledServerId(e){this.host=Object.assign({},this.host,{serverId:e}),this.snapshot=Object.assign({},this.snapshot,{serverId:e});for(const e of this.listeners)e()}resolveClientId(){return this.clientIdPromise||(this.clientIdPromise=this.deps.getClientId().then(e=>(this.clientIdHash=X(e),e))),this.clientIdPromise}}const le="@paseo:daemon-registry",he="localhost:6767",ue=2500,de="__PASEO_INITIAL_DAEMON_CONNECTION__",pe=b.z.object({listen:b.z.string().trim().min(1),useTls:b.z.boolean().optional().default(!1)});function ye(e){if(!(e?.isWebRuntime??v.isWeb)||"undefined"==typeof globalThis)return null;const t=pe.safeParse(Reflect.get(globalThis,de));return t.success?t.data:null}function ge(){return null}function Se(e){return e.startsWith("local:")}function ve(e){return new Promise(t=>setTimeout(t,e))}function fe(e,t,n){const s=e.get(t);void 0!==s&&(e.delete(t),e.set(n,s))}class Ce{controllers=new Map;serverListeners=new Map;globalListeners=new Set;hostListListeners=new Set;version=0;hostListVersion=0;hostRegistryLoaded=!1;hosts=[];hostAppearanceMutationTail=Promise.resolve();hostRegistryStatus="loading";lastConnectionStatusByServer=new Map;connectionStatusStartedAtByServer=new Map;queuedAgentDrainInFlight=new Set;directorySyncByServer=new Map;nextCancellationRequestId=0;timelineReplicaByServer=new Map;configuredOverrideBootstrapInFlight=null;bootPromise=null;constructor(e){this.deps=e?.deps??ce(),this.storage=e?.storage??s.default,this.replicaCache=new x.ReplicaCache(e?.replicaRowStore??(0,U.createReplicaRowStore)()),this.revokePushNotifications=e?.revokePushNotifications??$.revokePushNotifications}getHosts(){return this.hosts}getHostRegistryStatus(){return this.hostRegistryStatus}subscribeHostList(e){return this.hostListListeners.add(e),()=>{this.hostListListeners.delete(e)}}getHostListVersion(){return this.hostListVersion}isHostRegistryLoaded(){return this.hostRegistryLoaded}boot(){return this.bootPromise||(this.bootPromise=this.runBoot()),this.bootPromise}async runBoot(){await this.loadFromStorage(),this.markHostRegistryLoaded();let e=null;try{e=await(0,I.readValidatedString)(this.storage,"@paseo:e2e",b.z.string().min(1))}catch{return}if(e)return;if((0,S.shouldUseDesktopDaemon)())return;const t=this.deps.readInitialConnectionHint?this.deps.readInitialConnectionHint():ye();if(t){if(await this.bootstrapInitialConnectionHint(t))return}await this.bootstrapDefaultLocalhost()}async loadFromStorage(){let e=!1,t=[];try{const n=await(0,I.readValidatedJson)(this.storage,le,l.StoredHostRegistrySchema);if(n){const s=[];for(const e of n){const t=(0,l.normalizeStoredHostProfile)(e);if(!t){await this.storage.removeItem(le),s.length=0;break}s.push(t)}t=s.filter(e=>!Se(e.serverId)),t.length!==s.length&&(e=!0)}this.hosts=t,this.replicaCache.setHosts(t.map(e=>e.serverId)),W.projectIconCache.setHosts(t.map(e=>e.serverId)),await W.projectIconCache.restore(),this.syncHosts(t);for(const e of t)this.directorySyncByServer.get(e.serverId)?.restoreCachedDirectory().catch(()=>{})}catch(e){console.error("[HostRuntime] Failed to load host registry from storage",e)}finally{this.hostRegistryStatus="ready",this.emitHostList(),e&&this.persistHosts().catch(e=>console.error("[HostRuntime] Failed to persist host registry",e))}}markHostRegistryLoaded(){this.hostRegistryLoaded||(this.hostRegistryLoaded=!0,this.emitHostList())}async bootstrapDefaultLocalhost(){const e=(0,l.connectionFromListen)(he);if(e&&!(0,l.registryHasConnection)(this.hosts,e))try{await this.probeAndUpsertConnection({connection:e,timeoutMs:ue})}catch(e){console.warn("[HostRuntime] bootstrap probe failed",{endpoint:he,error:e})}}bootstrapConfiguredOverride(e){const t=(0,l.connectionFromListen)(e);if(!t)return;if((0,l.registryHasConnection)(this.hosts,t))return;if(this.configuredOverrideBootstrapInFlight)return;const n=this.runConfiguredOverrideBootstrap(e,t).finally(()=>{this.configuredOverrideBootstrapInFlight===n&&(this.configuredOverrideBootstrapInFlight=null)});this.configuredOverrideBootstrapInFlight=n}async runConfiguredOverrideBootstrap(e,t){let n=0;for(;!(0,l.registryHasConnection)(this.hosts,t);){n+=1;try{return void await this.probeAndUpsertConnection({connection:t,timeoutMs:ue})}catch(t){1!==n&&n%10!=0||console.warn("[HostRuntime] configured bootstrap probe failed",{endpoint:e,attempt:n,error:t}),await ve(1e3)}}}async bootstrapInitialConnectionHint(e){const t=(0,l.connectionFromListen)(e.listen);if(!t)return!1;const n="directTcp"===t.type?Object.assign({},t,{useTls:e.useTls??t.useTls??!1}):t;if((0,l.registryHasConnection)(this.hosts,n))return!0;try{return await this.probeAndUpsertConnection({connection:n,timeoutMs:ue}),!0}catch(t){return console.warn("[HostRuntime] initial connection hint probe failed",{listen:e.listen,useTls:e.useTls,error:t}),!1}}reconcileServerId(e,t){if(e===t)return;const n=this.controllers.get(e);if(!n)return;if(this.controllers.has(t))return;fe(this.controllers,e,t),fe(this.lastConnectionStatusByServer,e,t),fe(this.connectionStatusStartedAtByServer,e,t),this.replicaCache.reconcileServerId(e,t),W.projectIconCache.reconcileServerId(e,t),this.directorySyncByServer.get(e)?.dispose(),this.directorySyncByServer.delete(e),this.timelineReplicaByServer.delete(e);const s=new j.DirectorySync(t,{onAgentStoppedRunning:e=>this.drainQueuedAgentMessage(t,e),markAgentLoading:()=>n.markAgentDirectorySyncLoading(),markAgentReady:()=>n.markAgentDirectorySyncReady(),markAgentError:e=>n.markAgentDirectorySyncError(e)},this.replicaCache);this.directorySyncByServer.set(t,s),this.timelineReplicaByServer.set(t,(0,V.createTimelineReplica)({serverId:t,storage:this.replicaCache,prepareAgent:e=>s.prepareAgentRoute(e)})),n.adoptReconciledServerId(t);const o=n.getSnapshot();this.clearHostReplica(e),this.syncSessionReplica(t,o),s.connectionChanged({client:o.client,status:"online"===o.connectionStatus?"online":"offline",source:{clientGeneration:o.clientGeneration,connectionEpoch:o.connectionEpoch}});const c=this.serverListeners.get(e);if(c){this.serverListeners.delete(e);const n=this.serverListeners.get(t)??new Set;for(const e of c)n.add(e);this.serverListeners.set(t,n)}this.hosts=this.hosts.map(n=>n.serverId===e?Object.assign({},n,{serverId:t,updatedAt:(new Date).toISOString()}):n),this.emitHostList(),this.emit(t),this.persistHosts().catch(e=>console.error("[HostRuntime] Failed to persist host registry",e))}async upsertDirectConnection(e){const t=(0,u.normalizeHostPort)(e.endpoint),n=e.password?.trim();return this.upsertHostConnection({serverId:e.serverId,label:e.label,connection:Object.assign({id:`direct:${t}`,type:"directTcp",endpoint:t,useTls:e.useTls??!1},n?{password:n}:{}),existingClient:e.existingClient})}async probeAndUpsertConnection(e){if("relay"===e.connection.type)throw new Error("Cannot probe a relay connection without a server id.");const t={serverId:"",label:e.label??e.connection.id,appearance:(0,h.defaultHostAppearance)(),lifecycle:{},connections:[e.connection],preferredConnectionId:e.connection.id,createdAt:new Date(0).toISOString(),updatedAt:new Date(0).toISOString()},{client:n,serverId:s,hostname:o}=await this.deps.connectToDaemon(Object.assign({host:t,connection:e.connection},void 0!==e.timeoutMs?{timeoutMs:e.timeoutMs}:{}));return{profile:await this.upsertHostConnection({serverId:s,label:e.label??o??void 0,connection:e.connection,existingClient:n}),serverId:s,hostname:o}}async probeAndUpsertDirectConnection(e){const t=(0,u.normalizeHostPort)(e.endpoint),n=e.password?.trim();return this.probeAndUpsertConnection({label:e.label,connection:Object.assign({id:`direct:${t}`,type:"directTcp",endpoint:t,useTls:e.useTls??!1},n?{password:n}:{})})}async probeAndUpsertRemoteSshConnection(e){return this.probeAndUpsertConnection({label:e.label,connection:(0,l.createRemoteSshHostConnection)(e)})}async upsertRelayConnection(e){const t=(0,u.normalizeHostPort)(e.relayEndpoint),n=e.useTls??!1,s=e.daemonPublicKeyB64.trim();if(!s)throw new Error("daemonPublicKeyB64 is required");const o=void 0!==e.useTls;return this.upsertHostConnection({serverId:e.serverId,label:e.label,connection:Object.assign({id:n?`relay:wss:${t}`:`relay:${t}`,type:"relay",relayEndpoint:t},o?{useTls:n}:{},{daemonPublicKeyB64:s})})}async upsertConnectionFromOffer(e,t){const n=e.relay.useTls??(0,u.shouldUseTlsForDefaultHostedRelay)(e.relay.endpoint);return this.upsertRelayConnection({serverId:e.serverId,relayEndpoint:e.relay.endpoint,useTls:n,daemonPublicKeyB64:e.daemonPublicKeyB64,label:t})}async upsertConnectionFromOfferUrl(e,t){const n="#offer=",s=e.indexOf(n);if(-1===s)throw new Error("Missing #offer= fragment");const o=e.slice(s+7).trim();if(!o)throw new Error("Offer payload is empty");const c=(0,u.decodeOfferFragmentPayload)(o),l=y.ConnectionOfferSchema.parse(c);return this.upsertConnectionFromOffer(l,t)}async upsertConnectionFromListen(e){const t=e.listenAddress.trim(),n=e.serverId.trim(),s=(0,l.connectionFromListen)(t);if(!s)throw new Error(`Unsupported listen address: ${e.listenAddress}`);if(!n)throw new Error("Desktop daemon did not return a server id.");return this.upsertHostConnection({serverId:n,label:e.hostname??void 0,connection:s})}async updateHost(e,t){const n=(new Date).toISOString(),s=this.hosts.map(s=>s.serverId===e?Object.assign({},t(s),{updatedAt:n}):s);this.setHostsAndSync(s),await this.persistHosts()}async renameHost(e,t){await this.updateHost(e,e=>Object.assign({},e,{label:t}))}async setHostColor(e,t){await this.updateHostAppearance(e,e=>Object.assign({},e,{appearance:Object.assign({},e.appearance,{color:t})}))}async setHostBadgeDisplay(e,t){await this.updateHostAppearance(e,e=>Object.assign({},e,{appearance:Object.assign({},e.appearance,{badgeDisplay:t})}))}updateHostAppearance(e,t){const n=this.hostAppearanceMutationTail.then(()=>this.applyHostAppearance(e,t));return this.hostAppearanceMutationTail=n.catch(()=>{}),n}async applyHostAppearance(e,t){const n=(new Date).toISOString(),s=this.hosts.map(s=>s.serverId===e?Object.assign({},t(s),{updatedAt:n}):s);await this.persistHosts(s),this.setHostsAndSync(s)}async removeHost(e){await this.revokePushNotifications({client:this.getClient(e),serverId:e});const t=this.hosts.filter(t=>t.serverId!==e);this.setHostsAndSync(t),await this.persistHosts()}async removeConnection(e,t){const n=this.hosts.find(t=>t.serverId===e);if(1===n?.connections.length&&n.connections[0]?.id===t)return void await this.removeHost(e);const s=(new Date).toISOString(),o=this.hosts.map(n=>{if(n.serverId!==e)return n;const o=n.connections.filter(e=>e.id!==t);if(0===o.length)return null;const c=n.preferredConnectionId===t?o[0]?.id??null:n.preferredConnectionId;return Object.assign({},n,{connections:o,preferredConnectionId:c,updatedAt:s})}).filter(e=>null!==e);this.setHostsAndSync(o),await this.persistHosts()}async upsertHostConnection(e){const t=(new Date).toISOString(),n=(0,l.upsertHostConnectionInProfiles)({profiles:this.hosts,serverId:e.serverId,label:e.label,connection:e.connection,now:t});this.setHostsAndSync(n,{initialConnectionByServerId:e.existingClient?new Map([[e.serverId,{connectionId:e.connection.id,existingClient:e.existingClient}]]):void 0}),this.persistHosts().catch(e=>console.error("[HostRuntime] Failed to persist host registry",e));const s=n.find(t=>t.serverId===e.serverId);if(!s)throw new Error(`Host ${e.serverId} was not inserted`);return s}setHostsAndSync(e,t){this.hosts=e,this.syncHosts(e,t),this.emitHostList()}async persistHosts(e=this.hosts){await this.storage.setItem(le,JSON.stringify(e))}emitHostList(){this.hostListVersion+=1;for(const e of this.hostListListeners)e()}syncHosts(e,t){this.replicaCache.setHosts(e.map(e=>e.serverId)),W.projectIconCache.setHosts(e.map(e=>e.serverId));const n=new Set(e.map(e=>e.serverId));for(const[e,t]of this.controllers)n.has(e)||(this.controllers.delete(e),this.lastConnectionStatusByServer.delete(e),this.connectionStatusStartedAtByServer.delete(e),this.directorySyncByServer.get(e)?.dispose(),this.directorySyncByServer.delete(e),this.timelineReplicaByServer.delete(e),this.clearHostReplica(e),t.stop(),this.emit(e));for(const n of e){const e=t?.initialConnectionByServerId?.get(n.serverId),s=this.controllers.get(n.serverId);if(s){s.updateHost(n),e&&s.activateConnection(e).catch(()=>{e.existingClient.close().catch(()=>{})});continue}const o=new ae({host:n,deps:this.deps,onReconcileServerId:(e,t)=>this.reconcileServerId(e,t)});this.controllers.set(n.serverId,o),E.useSessionStore.getState().initializeSession(n.serverId,null);const c=new j.DirectorySync(n.serverId,{onAgentStoppedRunning:e=>this.drainQueuedAgentMessage(n.serverId,e),markAgentLoading:()=>o.markAgentDirectorySyncLoading(),markAgentReady:()=>o.markAgentDirectorySyncReady(),markAgentError:e=>o.markAgentDirectorySyncError(e)},this.replicaCache);this.directorySyncByServer.set(n.serverId,c),this.timelineReplicaByServer.set(n.serverId,(0,V.createTimelineReplica)({serverId:n.serverId,storage:this.replicaCache,prepareAgent:e=>c.prepareAgentRoute(e)}));const l=o.getSnapshot();this.lastConnectionStatusByServer.set(n.serverId,l.connectionStatus),this.connectionStatusStartedAtByServer.set(n.serverId,Date.now()),o.subscribe(()=>{const e=o.getSnapshot();this.syncSessionReplica(e.serverId,e),this.syncDirectoryConnection(e.serverId),this.emit(e.serverId)}),o.start(e?{initialConnection:e}:{}).catch(e=>{const t=e instanceof Error?e.message:String(e);o.markStartupError(t)}),this.emit(n.serverId)}}syncSessionReplica(e,t){if(!t.client)return;const n=E.useSessionStore.getState();n.initializeSession(e,t.client,t.clientGeneration),n.updateSessionClient(e,t.client,t.clientGeneration)}clearHostReplica(e){E.useSessionStore.getState().clearSession(e),P.useWorkspaceSetupStore.getState().clearServer(e)}syncDirectoryConnection(e){const t=this.controllers.get(e);if(!t)return this.lastConnectionStatusByServer.delete(e),void this.connectionStatusStartedAtByServer.delete(e);const n=t.getSnapshot(),s=this.directorySyncByServer.get(e);s?.connectionChanged({client:n.client,status:"online"===n.connectionStatus?"online":"offline",source:{clientGeneration:n.clientGeneration,connectionEpoch:n.connectionEpoch}});const o=this.lastConnectionStatusByServer.get(e),c=o!==n.connectionStatus,l="online"!==n.connectionStatus&&"idle"!==n.connectionStatus;!c||void 0!==o&&"online"!==o&&"idle"!==o&&l||this.connectionStatusStartedAtByServer.set(e,Date.now()),this.lastConnectionStatusByServer.set(e,n.connectionStatus);"online"===n.connectionStatus&&"online"!==o&&(E.useSessionStore.getState().bumpHistorySyncGeneration(e),(0,O.invalidateCheckoutGitQueriesForServer)(L.queryClient,e),(0,_.invalidateServerDataQueriesAfterReconnect)({queryClient:L.queryClient,serverId:e}),L.queryClient.invalidateQueries({queryKey:M.schedulesQueryBaseKey}))}drainQueuedAgentMessage(e,t){const n=`${e}:${t}`;if(this.queuedAgentDrainInFlight.has(n))return;const s=E.useSessionStore.getState().sessions[e],o=s?.queuedMessages.get(t),c=s?.client;if(!c||!o?.length||!0===s.initializingAgents.get(t))return;this.queuedAgentDrainInFlight.add(n);const l=o[0];(0,B.sendQueuedComposerMessageNow)({agentId:t,messageId:l.id,queue:{read:t=>E.useSessionStore.getState().sessions[e]?.queuedMessages.get(t)??[],write:t=>E.useSessionStore.getState().setQueuedMessages(e,t)},submitMessage:async({text:n,attachments:s})=>{const o=!0===E.useSessionStore.getState().sessions[e]?.serverInfo?.features?.forgeSearch;await(0,B.dispatchComposerAgentMessage)({client:c,agentId:t,text:n,attachments:s,attachmentSubmitFormat:(0,F.resolveComposerAttachmentSubmitFormat)({supportsForgeAttachments:o}),encodeImages:q.encodeImages,submission:(0,k.createMessageSubmissionWriter)(e)})}}).then(n=>("failed"===n.status&&console.error("[HostRuntime] failed to drain queued agent message",{serverId:e,agentId:t,error:n.errorMessage}),n)).finally(()=>{this.queuedAgentDrainInFlight.delete(n)})}applyAgentTurnLiveness(e,t,n){this.directorySyncByServer.get(e)?.applyAgentTurnLiveness(t,n)}beginAgentCancellation(e,t){const n=++this.nextCancellationRequestId;return this.applyAgentTurnLiveness(e,t,{type:"cancellation_started",requestId:n}),n}settleAgentCancellation(e,t,n){this.applyAgentTurnLiveness(e,t,{type:"cancellation_settled",requestId:n})}acceptAgentSnapshot(e,t){return this.requireDirectory(e).acceptAgent(t)}archiveAgentSnapshot(e,t,n){this.requireDirectory(e).archiveAgent(t,n)}restoreAgentSnapshot(e,t,n){const s=this.requireDirectory(e);n?s.acceptAgent(n):s.removeAgent(t)}acceptWorkspaceSnapshots(e,t){this.requireDirectory(e).acceptWorkspaces(t)}acceptProjectSnapshot(e,t){this.requireDirectory(e).acceptProject(t)}removeWorkspaceSnapshot(e,t){this.requireDirectory(e).removeWorkspace(t)}requireDirectory(e){const t=this.directorySyncByServer.get(e);if(!t)throw new Error(`Unknown host runtime for serverId ${e}`);return t}getSnapshot(e){return this.controllers.get(e)?.getSnapshot()??null}getConnectionStatusSince(e){return this.connectionStatusStartedAtByServer.get(e)??null}getVersion(){return this.version}getClient(e){return this.controllers.get(e)?.getClient()??null}subscribe(e,t){const n=this.serverListeners.get(e)??new Set;return n.add(t),this.serverListeners.set(e,n),()=>{const n=this.serverListeners.get(e);n&&(n.delete(t),0===n.size&&this.serverListeners.delete(e))}}subscribeAll(e){return this.globalListeners.add(e),()=>{this.globalListeners.delete(e)}}getEarliestOnlineHostServerId(){let e=null,t=null;for(const n of this.hosts){const s=this.getSnapshot(n.serverId);Q(s)&&s?.lastOnlineAt&&((!t||s.lastOnlineAt<t)&&(t=s.lastOnlineAt,e=n.serverId))}return e}ensureConnectedAll(e){for(const t of this.controllers.values())t.ensureConnected(e)}setAppVisible(e){e?this.ensureConnectedAll({verify:!0}):this.replicaCache.flush()}runProbeCycleNow(e){return e?this.controllers.get(e)?.runProbeCycleNow()??Promise.resolve():Promise.all(Array.from(this.controllers.values(),e=>e.runProbeCycleNow())).then(()=>{})}async refreshAgentDirectory(e){const t=this.directorySyncByServer.get(e.serverId);if(!t)throw new Error(`Unknown host runtime for serverId ${e.serverId}`);return t.refreshAgents(e)}async refreshWorkspaceDirectory(e){const t=this.directorySyncByServer.get(e.serverId);if(!t)throw new Error(`Unknown host runtime for serverId ${e.serverId}`);await t.refreshWorkspaces({subscribe:e.subscribe})}async refreshDirectories(e){const t=this.directorySyncByServer.get(e);if(!t)throw new Error(`Unknown host runtime for serverId ${e}`);await t.refreshDemand()}acquireDirectoryDemand(e){const t=this.directorySyncByServer.get(e);if(!t)return()=>{};const n={};return t.setDemand(n,!0),()=>t.setDemand(n,!1)}async prepareAgentRoute(e,t){const n=this.directorySyncByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);await n.prepareAgentRoute(t)}async prepareWorkspaceRoute(e,t){const n=this.directorySyncByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);await n.prepareWorkspaceRoute(t)}async prepareAgentTimeline(e,t){const n=this.timelineReplicaByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);await n.prepare(t)}async fetchAgentTimeline(e,t,n){const s=this.directorySyncByServer.get(e);if(!s)throw new Error(`Unknown host runtime for serverId ${e}`);const o=E.useSessionStore.getState().sessions[e]?.viewedTimelineSync,c=await s.fetchTimeline(t,n);return o&&E.useSessionStore.getState().sessions[e]?.viewedTimelineSync===o&&(o.flushStreamAgent(t),o.applyTimelineResponse(c)),c}createViewedTimelineOwner(e,t){const n=this.directorySyncByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);const s=this.timelineReplicaByServer.get(e);if(!s)throw new Error(`Unknown host runtime for serverId ${e}`);return(0,V.createViewedTimelineOwner)({serverId:e,replica:s,replaceDemandedAgentIds:e=>n.setAgentRouteDemand(e),drainQueuedAgentMessage:t=>this.drainQueuedAgentMessage(e,t),ports:t})}emit(e){this.version+=1;const t=this.serverListeners.get(e);if(t){for(const e of t)e();for(const e of this.globalListeners)e()}else for(const e of this.globalListeners)e()}}let me=null;const be="__paseoHostRuntimeStore";function Ie(){if(me)return me;const e=Reflect.get(globalThis,be);return e instanceof Ce?(me=e,e):(me=new Ce,Reflect.set(globalThis,be,me),me)}},3466,[453,36,884,3467,3468,3518,3521,3523,3463,3524,3525,880,3527,3528,2898,2979,3531,3529,881,3479,3491,3420,3532,3539,848,3541,3552,3570,3572,3583,3574,3584,3590,3620,3624,3625,3629,3631,3633,3634]);
|
|
15112
15112
|
__d(function(g,r,_i,_a,m,e,d){'use strict';m.exports=function t(n,f){if(n===f)return!0;if(n&&f&&'object'==typeof n&&'object'==typeof f){if(n.constructor!==f.constructor)return!1;var i,o,u;if(Array.isArray(n)){if((i=n.length)!=f.length)return!1;for(o=i;0!==o--;)if(!t(n[o],f[o]))return!1;return!0}if(n instanceof Map&&f instanceof Map){if(n.size!==f.size)return!1;for(o of n.entries())if(!f.has(o[0]))return!1;for(o of n.entries())if(!t(o[1],f.get(o[0])))return!1;return!0}if(n instanceof Set&&f instanceof Set){if(n.size!==f.size)return!1;for(o of n.entries())if(!f.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(n)&&ArrayBuffer.isView(f)){if((i=n.length)!=f.length)return!1;for(o=i;0!==o--;)if(n[o]!==f[o])return!1;return!0}if(n.constructor===RegExp)return n.source===f.source&&n.flags===f.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===f.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===f.toString();if((i=(u=Object.keys(n)).length)!==Object.keys(f).length)return!1;for(o=i;0!==o--;)if(!Object.prototype.hasOwnProperty.call(f,u[o]))return!1;for(o=i;0!==o--;){var s=u[o];if(!t(n[s],f[s]))return!1}return!0}return n!=n&&f!=f}},3467,[]);
|
|
@@ -15267,7 +15267,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
15267
15267
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"REPLICA_ROW_STORE_SCHEMA_VERSION",{enumerable:!0,get:function(){return t.REPLICA_ROW_STORE_SCHEMA_VERSION}}),Object.defineProperty(e,"REPLICA_SINGLETON_ROW_ID",{enumerable:!0,get:function(){return t.REPLICA_SINGLETON_ROW_ID}}),e.createIndexedDbReplicaRowStore=b,e.createReplicaRowStore=function(){return b({databaseName:n,schemaVersion:t.REPLICA_ROW_STORE_SCHEMA_VERSION})};var t=r(d[0]);const n="paseo-replica-row-store",o=1,c="rows",s="meta",l="schema_version";function u(t){return new Promise((n,o)=>{t.addEventListener("success",()=>n(t.result)),t.addEventListener("error",()=>o(t.error??new Error("Replica row store request failed")))})}function w(t){return new Promise((n,o)=>{t.addEventListener("complete",()=>n()),t.addEventListener("abort",()=>o(t.error??new Error("Replica row store transaction was aborted"))),t.addEventListener("error",()=>o(t.error??new Error("Replica row store transaction failed")))})}async function f(t,n,o){const c=t.transaction(n,"readwrite"),s=w(c);try{await o(c),await s}catch(t){try{c.abort()}catch{}throw await s.catch(()=>{}),t}}async function p(t){return new Promise((n,l)=>{const u=indexedDB.open(t,o);u.addEventListener("upgradeneeded",()=>{u.result.objectStoreNames.contains(c)||u.result.createObjectStore(c,{keyPath:["serverId","kind","id"]}),u.result.objectStoreNames.contains(s)||u.result.createObjectStore(s)}),u.addEventListener("success",()=>n(u.result)),u.addEventListener("error",()=>l(u.error??new Error("Failed to open replica row store"))),u.addEventListener("blocked",()=>l(new Error("Replica row store database open was blocked")))})}function b(t){let n=null,o=null;function b(){if(!n)throw new Error("Replica row store has not been opened");return n}return{open:async function(){o??=(async()=>{const o=await p(t.databaseName);await f(o,[c,s],async n=>{await u(n.objectStore(s).get(l))!==t.schemaVersion&&(await u(n.objectStore(c).clear()),await u(n.objectStore(s).put(t.schemaVersion,l)))}),n=o})();try{await o}catch(t){throw o=null,t}},read:async function(t,n,o){if(0===n.length||0===o?.length)return[];const s=b().transaction(c,"readonly"),l=w(s),f=s.objectStore(c),p=o?n.flatMap(n=>o.map(async o=>{const c=await u(f.get([t,n,o]));return c?[c]:[]})):n.map(n=>u(f.getAll(IDBKeyRange.bound([t,n],[t,n,[]])))),E=(await Promise.all(p)).flat();return await l,E.sort((t,n)=>t.kind===n.kind?t.id.localeCompare(n.id):t.kind.localeCompare(n.kind))},readAll:async function(){const t=b().transaction(c,"readonly"),n=w(t),o=await u(t.objectStore(c).getAll());await n;const s=new Map;for(const t of o){const n=s.get(t.serverId)??[];n.push(t),s.set(t.serverId,n)}return Array.from(s,([t,n])=>({serverId:t,rows:n}))},apply:async function(t){await f(b(),c,async n=>{const o=n.objectStore(c);for(const n of t.deletes)await u(o.delete([n.serverId,n.kind,n.id]));for(const n of t.upserts)await u(o.put(n))})},deleteHost:async function(t){await f(b(),c,async n=>{const o=n.objectStore(c),s=IDBKeyRange.bound([t],[t,[]]);await u(o.delete(s))})},renameHost:async function(t,n){t!==n&&await f(b(),c,async o=>{const s=o.objectStore(c),l=IDBKeyRange.bound([t],[t,[]]),w=await u(s.getAll(l));for(const t of w)await u(s.put(Object.assign({},t,{serverId:n}))),await u(s.delete([t.serverId,t.kind,t.id]))})},clear:async function(){await f(b(),c,async t=>{await u(t.objectStore(c).clear())})}}}},3622,[3623]);
|
|
15268
15268
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"REPLICA_ROW_STORE_SCHEMA_VERSION",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"REPLICA_SINGLETON_ROW_ID",{enumerable:!0,get:function(){return n}});const t=1,n="singleton"},3623,[]);
|
|
15269
15269
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"createReplicaRowStore",{enumerable:!0,get:function(){return t.createReplicaRowStore}});var t=r(d[0])},3624,[3622]);
|
|
15270
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createTimelineReplica=function(t){return new f(t.serverId,t.storage,t.prepareAgent)},e.consumeForcedTimelineTailReplacement=h,e.createViewedTimelineOwner=function(t){const n=new Set,o=M(Object.assign({},t.ports,{fetchLatestTail:async s=>{n.add(s);try{return await t.ports.fetchLatestTail(s)}finally{n.delete(s)}},prepare:s=>t.replica.prepare(s),readCursor:s=>t.replica.readCursor(s)??t.ports.readCursor(s),replaceDemandedAgentIds:t.replaceDemandedAgentIds})),c=(0,l.createSessionAgentStreamReducerQueue)({serverId:t.serverId,setAgentStreamState:(...t)=>s.useSessionStore.getState().setAgentStreamState(...t),setAgentTimelineCursor:(...t)=>s.useSessionStore.getState().setAgentTimelineCursor(...t),recoverTimelineGap:(t,s)=>o.recoverGap(t,s),onCommitted:s=>t.replica.timelineUpdated(s)});return Object.assign({},o,{applyTimelineResponse(s){const c=h(s,n);y({serverId:t.serverId,payload:c,cachedCursor:t.replica.readRange(c.agentId),recoverGap:(t,s)=>o.recoverGap(t,s),drainQueuedAgentMessage:t.drainQueuedAgentMessage})&&t.replica.timelineUpdated(c.agentId)},enqueueStreamEvent(t,s){c.enqueue(t,s)},flushStreamAgent(t){c.flushAgent(t)},dispose(){c.dispose({flush:!0}),o.dispose()}})},e.createViewedTimelineSync=M;var t=r(d[0]),s=r(d[1]),n=r(d[2]),o=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]);async function p(t){const n=s.useSessionStore.getState().sessions[t.serverId],c=(0,s.selectAgentTimelineState)(n,t.agentId);if("synced"===c.status)return;const[l]=await Promise.all([t.storage.readTimeline(t.serverId,t.agentId),t.prepareAgent(t.agentId)]);if(!l)return;const p=s.useSessionStore.getState().sessions[t.serverId],f=(0,s.selectAgentTimelineState)(p,t.agentId),h=p?.agentStreamHead.get(t.agentId);if("synced"===f.status)return;if(!l.range){if("painted"===c.status)return"painted"===f.status&&f.items===c.items?l:void 0;if("cold"!==f.status)return}const S="painted"===f.status?[...f.items,...h??[]]:h??[],I=(0,u.replaceWithCanonicalStream)({canonical:l.items,previousTail:[],previousHead:S,sendingClientMessageIds:(0,o.getSendingClientMessageIds)(p?.messageSubmissions.get(t.agentId)),preserveContinuity:!0,canonicalCoverage:l.range??{epoch:S.find(t=>t.timelineCursor)?.timelineCursor?.epoch??"",endSeq:null}});return s.useSessionStore.getState().applyAgentTimelineResponseState(t.serverId,t.agentId,{items:I.tail,head:I.head,range:l.range,older:l.hasOlder?"available":"none",newer:!1,synchronized:!1,acknowledgedClientMessageIds:I.acknowledgedClientMessageIds}),l}class f{cachedRanges=new Map;preparations=new Map;constructor(t,s,n){this.serverId=t,this.storage=s,this.prepareAgent=n}async prepare(t){const s=this.preparations.get(t);if(s)return s;const n=this.load(t).finally(()=>{this.preparations.get(t)===n&&this.preparations.delete(t)});return this.preparations.set(t,n),n}async load(t){const s=await p({serverId:this.serverId,agentId:t,storage:this.storage,prepareAgent:this.prepareAgent});s&&s.range&&this.cachedRanges.set(t,s.range)}readCursor(t){const s=this.cachedRanges.get(t);return s?{epoch:s.epoch,endSeq:s.endSeq}:void 0}readRange(t){return this.cachedRanges.get(t)}timelineUpdated(t){const n=s.useSessionStore.getState().sessions[this.serverId],o=(0,s.selectAgentTimelineState)(n,t);"cold"!==o.status&&("synced"===o.status&&this.cachedRanges.delete(t),this.storage.commitTimeline(this.serverId,t,{agentId:t,items:[...o.items,...n?.agentStreamHead.get(t)??[]],range:"synced"===o.status?o.range:null,hasOlder:"synced"===o.status&&"available"===o.older}))}}function h(t,s){return"tail"!==t.direction?t:s.delete(t.agentId)?Object.assign({},t,{reset:!0}):t}function S(t,n){s.useSessionStore.getState().setInitializingAgents(t,t=>{if(!0!==t.get(n))return t;const s=new Map(t);return s.set(n,!1),s})}function I(t){const{serverId:n,payload:o,result:c,timeline:l,currentCursor:u,synchronized:p}=t,f=o.agentId,h=s.useSessionStore.getState();"discard"===c.commit?(c.acknowledgedClientMessageIds.length>0&&h.setAgentStreamState(n,f,{acknowledgedClientMessageIds:c.acknowledgedClientMessageIds}),"before"!==o.direction&&h.setAgentTimelineHasNewer(n,t=>{const s=new Map(t);return s.set(f,o.hasNewer),s}),h.markAgentHistorySynchronized(n,f)):h.applyAgentTimelineResponseState(n,f,{items:c.tail,head:c.head,range:c.cursorChanged?c.cursor??null:u??null,older:c.older,newer:"before"===o.direction?"synced"===l.status&&"available"===l.newer:o.hasNewer,synchronized:p,acknowledgedClientMessageIds:c.acknowledgedClientMessageIds})}function v(t){for(const s of t.result.sideEffects)"catch_up"===s.type&&t.recoverGap(t.agentId,s.cursor);if(t.result.clearInitializing&&S(t.serverId,t.agentId),t.synchronized){n.useCreateFlowStore.getState().clearByAgent({serverId:t.serverId,agentId:t.agentId});const o=s.useSessionStore.getState().sessions[t.serverId],c=o?.agents.get(t.agentId)??o?.agentDetails.get(t.agentId);c&&"idle"===c.turn.phase&&t.drainQueuedAgentMessage(t.agentId)}"resolve"===t.result.initResolution&&(0,c.resolveInitDeferred)(t.initKey)}function y(n){const{serverId:u,payload:p}=n,f=p.agentId,h=(0,c.getInitKey)(u,f),y=s.useSessionStore.getState().sessions[u],w=(0,s.selectAgentTimelineState)(y,f),A=(0,c.getInitDeferred)(h),C="synced"===w.status?w.range??void 0:n.cachedCursor,M=(0,l.processTimelineResponse)({payload:p,currentTail:"cold"===w.status?[]:w.items,currentHead:y?.agentStreamHead.get(f)??[],currentCursor:C,isInitializing:!0===y?.initializingAgents.get(f),hasActiveInitDeferred:Boolean(A),initRequestDirection:A?.requestDirection??"tail",sendingClientMessageIds:(0,o.getSendingClientMessageIds)(y?.messageSubmissions.get(f))});if(M.error)return M.clearInitializing&&S(u,f),"reject"===M.initResolution&&(0,c.rejectInitDeferred)(h,new Error(M.error)),!1;const T=(0,t.isTimelineResumeSnapshotAuthoritative)({direction:p.direction,hasNewer:p.hasNewer,error:p.error});return I({serverId:u,payload:p,result:M,timeline:w,currentCursor:C,synchronized:T}),v({serverId:u,agentId:f,initKey:h,result:M,synchronized:T,recoverGap:n.recoverGap,drainQueuedAgentMessage:n.drainQueuedAgentMessage}),!0}const w=t=>null==t?1e3:Math.min(2*t,3e4);function A(t){return[...new Set(t)].filter(Boolean).sort()}function C(t,s){return t.length===s.length&&t.every((t,n)=>t===s[n])}function M(s){const n=new Map,o=new Map,c=new Map,l=new Map,u=new Set,p=new Map,f=new Set,h=new Set,S=new Map,I=new Set;let v,y=!0,M=!1,T=null,q=!1,R=[],b=[],k=0,D=!1,z=null,E=[];const G=()=>A([...n.values()].flat()),N=t=>b.includes(t),O=t=>R.includes(t),H=t=>!q&&M&&O(t)&&N(t),U=(t,s)=>H(t)&&o.get(t)?.generation===s,j=()=>{for(const t of I)t()},Q=t=>{const s=u.delete(t),n=p.delete(t),o=f.delete(t);(s||n||o)&&j()},B=(t,s)=>{const n=s instanceof Error?s.message:String(s);let o=!1;for(const s of t)f.delete(s)&&(o=!0),u.delete(s)&&(o=!0),p.get(s)!==n&&(p.set(s,n),o=!0);o&&j()},_=t=>{c.set(t,(c.get(t)??0)+1),o.get(t)?.cancelRetry?.(),o.delete(t),l.delete(t)},V=async(n,c,u,p)=>{if(U(n,c))try{const f=await s.fetchPage(n,u);if(!U(n,c))return;if(f.hasNewer&&f.endCursor){if(p){if(await s.fetchLatestTail(n),!U(n,c))return;return o.set(n,{generation:c,status:"complete"}),void Q(n)}return void await V(n,c,(0,t.planTimelineCatchUpAfter)(f.endCursor),!1)}if(f.hasNewer)throw new Error(`Timeline page for ${n} hasNewer without an end cursor`);o.set(n,{generation:c,status:"complete"});const h=l.get(n);if(h)return void L(n,{request:h,supersede:!0});Q(n)}catch(t){if(o.get(n)?.generation===c){const l=w(o.get(n)?.retryDelayMs),p=s.schedule(()=>{const t=o.get(n);t?.generation===c&&"error"===t.status&&L(n)},l);o.set(n,{generation:c,status:"error",request:u,cancelRetry:p,retryDelayMs:l}),B([n],t),s.reportError(t)}}finally{P()}},F=t=>{if(h.has(t)||S.has(t))return;const n=s.prepare(t).catch(t=>s.reportError(t)).finally(()=>{S.delete(t),h.add(t);const s=l.get(t);L(t,{request:s,supersede:Boolean(s)})});S.set(t,n)},K=t=>{if(!y||o.has(t))return!1;const s=G();return!s.includes(t)&&s.some(t=>{const s=o.get(t)?.status;return O(t)&&(void 0===s||"running"===s)})},L=(n,u={})=>{const{request:p,supersede:f=!1}=u;if(!H(n))return void(p&&l.set(n,p));if(K(n))return void(p&&l.set(n,p));if(!h.has(n))return p&&l.set(n,p),void F(n);const S=p??(0,t.planTimelineResumeFetch)(s.readCursor(n)),I=o.get(n),v=(y={current:I,request:S,supersede:f}).current?y.supersede?"running"===y.current.status&&(w=y.current.request,A=y.request,w&&A&&w.direction===A.direction&&("after"!==w.direction||"after"!==A.direction||w.cursor.epoch===A.cursor.epoch&&w.cursor.seq===A.cursor.seq))?"keep":"running"===y.current.status&&"tail"===y.current.request?.direction?"keep-and-park":"replace":"running"===y.current.status||"complete"===y.current.status?"keep":"replace":"replace";var y,w,A;if("keep-and-park"===v)return void l.set(n,S);if("keep"===v)return;I?.cancelRetry?.();const C=(c.get(n)??0)+1;c.set(n,C);const M=f||"error"!==I?.status?void 0:I.retryDelayMs;o.set(n,{generation:C,status:"running",request:S,retryDelayMs:M}),l.delete(n),V(n,C,S,void 0===p&&"after"===S.direction)},P=()=>{const t=G(),s=[...t.filter(N),...b.filter(s=>!t.includes(s))];for(const t of s){const s=l.get(t),n=o.get(t);(!n||"complete"===n.status&&s)&&L(t,{request:s,supersede:Boolean(s)})}},W=async()=>{if(q||!M)return;const t=k,n=R;if(D||!C(n,T?.agentIds??b)){D=!1;try{const t=T,o=s.observe(n);T={handle:o,agentIds:n},t?.handle.release().catch(s.reportError),await o.ready}catch(o){if(q||!M||t!==k)return;D=!0,B(n,o),z?.();const c=w(v);return z=s.schedule(()=>{z=null,!q&&M&&k===t&&W()},c),v=c,void s.reportError(o)}!q&&M&&t===k&&(z?.(),z=null,v=void 0,b=n,P())}},$=(t,n={})=>{let o=!1;if(n.resetCatchUpStatus)for(const s of t)u.has(s)||(u.add(s),o=!0),p.delete(s)&&(o=!0),f.delete(s)&&(o=!0);if(C(t,R))o&&j();else{for(const s of R)t.includes(s)||(_(s),u.delete(s),p.delete(s),f.delete(s));for(const s of t)R.includes(s)||(u.add(s),p.delete(s),f.delete(s),F(s));z?.(),z=null,R=t,s.replaceDemandedAgentIds(R),k+=1,j(),W()}},x=()=>{$(A([...E,...G()]))};return{subscribe:t=>(I.add(t),()=>I.delete(t)),getAgentTimelineStatus:t=>f.has(t)?"retrying":p.has(t)?"error":!O(t)||u.has(t)?"pending":"ready",getAgentTimelineError:t=>p.get(t)??null,replaceOpenAgentIds(t){const s=A(t);C(s,E)||(E=s,x())},replaceVisibleAgentIds(t,s){const o=A(s);0===o.length?n.delete(t):n.set(t,o),x(),P()},setActive(t){if(y!==t)if(y=t,x(),y){for(const t of G())u.add(t),p.delete(t),L(t,{supersede:!0});j()}else P()},setConnected(t){if(M!==t)if(M=t,M)k+=1,W();else{$(R,{resetCatchUpStatus:!0}),z?.(),z=null,v=void 0,T?.handle.release().catch(s.reportError),T=null,b=[],k+=1;for(const t of R)_(t)}},recoverGap(s,n){O(s)&&L(s,{request:(0,t.planTimelineCatchUpAfter)({epoch:n.epoch,seq:n.endSeq}),supersede:!0})},dispose(){q=!0,T?.handle.release().catch(s.reportError),T=null,z?.(),z=null,D=!1,v=void 0,n.clear(),k+=1;for(const t of R)_(t);R=[],s.replaceDemandedAgentIds([]),b=[],E=[],h.clear(),S.clear(),u.clear(),p.clear(),f.clear(),j(),I.clear()},retryVisibleAgentTimeline:t=>{if(!O(t)||f.has(t))return;const s=o.get(t),n=D&&M;if("error"===s?.status||n){if(f.add(t),j(),"error"===s?.status)return s.cancelRetry?.(),void L(t,{request:s.request,supersede:!0});z?.(),z=null,v=void 0,W()}}}}},3625,[3626,3420,3605,3428,3611,3628,3425]);
|
|
15270
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createTimelineReplica=function(t){return new f(t.serverId,t.storage,t.prepareAgent)},e.consumeForcedTimelineTailReplacement=h,e.createViewedTimelineOwner=function(t){const s=new Set,o=T(Object.assign({},t.ports,{fetchLatestTail:async n=>{s.add(n);try{return await t.ports.fetchLatestTail(n)}finally{s.delete(n)}},prepare:n=>t.replica.prepare(n),readCursor:n=>t.replica.readCursor(n)??t.ports.readCursor(n),replaceDemandedAgentIds:t.replaceDemandedAgentIds})),c=(0,l.createSessionAgentStreamReducerQueue)({serverId:t.serverId,setAgentStreamState:(...t)=>n.useSessionStore.getState().setAgentStreamState(...t),setAgentTimelineCursor:(...t)=>n.useSessionStore.getState().setAgentTimelineCursor(...t),recoverTimelineGap:(t,n)=>o.recoverGap(t,n),onCommitted:n=>t.replica.timelineUpdated(n)});return Object.assign({},o,{applyTimelineResponse(n){const c=h(n,s);y({serverId:t.serverId,payload:c,cachedCursor:t.replica.readRange(c.agentId),recoverGap:(t,n)=>o.recoverGap(t,n),drainQueuedAgentMessage:t.drainQueuedAgentMessage})&&t.replica.timelineUpdated(c.agentId)},enqueueStreamEvent(t,n){c.enqueue(t,n)},flushStreamAgent(t){c.flushAgent(t)},dispose(){c.dispose({flush:!0}),o.dispose()}})},e.createViewedTimelineSync=T;var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]);async function p(t){const s=n.useSessionStore.getState().sessions[t.serverId],c=(0,n.selectAgentTimelineState)(s,t.agentId);if("synced"===c.status)return;const[l]=await Promise.all([t.storage.readTimeline(t.serverId,t.agentId),t.prepareAgent(t.agentId)]);if(!l)return;const p=n.useSessionStore.getState().sessions[t.serverId],f=(0,n.selectAgentTimelineState)(p,t.agentId),h=p?.agentStreamHead.get(t.agentId);if("synced"===f.status)return;if(!l.range){if("painted"===c.status)return"painted"===f.status&&f.items===c.items?l:void 0;if("cold"!==f.status)return}const S="painted"===f.status?[...f.items,...h??[]]:h??[],I=(0,u.replaceWithCanonicalStream)({canonical:l.items,previousTail:[],previousHead:S,sendingClientMessageIds:(0,o.getSendingClientMessageIds)(p?.messageSubmissions.get(t.agentId)),preserveContinuity:!0,canonicalCoverage:l.range??{epoch:S.find(t=>t.timelineCursor)?.timelineCursor?.epoch??"",endSeq:null}});return n.useSessionStore.getState().applyAgentTimelineResponseState(t.serverId,t.agentId,{items:I.tail,head:I.head,range:l.range,older:l.hasOlder?"available":"none",newer:!1,synchronized:!1,acknowledgedClientMessageIds:I.acknowledgedClientMessageIds}),l}class f{cachedRanges=new Map;preparations=new Map;constructor(t,n,s){this.serverId=t,this.storage=n,this.prepareAgent=s}async prepare(t){const n=this.preparations.get(t);if(n)return n;const s=this.load(t).finally(()=>{this.preparations.get(t)===s&&this.preparations.delete(t)});return this.preparations.set(t,s),s}async load(t){const n=await p({serverId:this.serverId,agentId:t,storage:this.storage,prepareAgent:this.prepareAgent});n&&n.range&&this.cachedRanges.set(t,n.range)}readCursor(t){const n=this.cachedRanges.get(t);return n?{epoch:n.epoch,endSeq:n.endSeq}:void 0}readRange(t){return this.cachedRanges.get(t)}timelineUpdated(t){const s=n.useSessionStore.getState().sessions[this.serverId],o=(0,n.selectAgentTimelineState)(s,t);"cold"!==o.status&&("synced"===o.status&&this.cachedRanges.delete(t),this.storage.commitTimeline(this.serverId,t,{agentId:t,items:[...o.items,...s?.agentStreamHead.get(t)??[]],range:"synced"===o.status?o.range:null,hasOlder:"synced"===o.status&&"available"===o.older}))}}function h(t,n){return"tail"!==t.direction?t:n.delete(t.agentId)?Object.assign({},t,{reset:!0}):t}function S(t,s){n.useSessionStore.getState().setInitializingAgents(t,t=>{if(!0!==t.get(s))return t;const n=new Map(t);return n.set(s,!1),n})}function I(t){const{serverId:s,payload:o,result:c,timeline:l,currentCursor:u,synchronized:p}=t,f=o.agentId,h=n.useSessionStore.getState();"discard"===c.commit?(c.acknowledgedClientMessageIds.length>0&&h.setAgentStreamState(s,f,{acknowledgedClientMessageIds:c.acknowledgedClientMessageIds}),"before"!==o.direction&&h.setAgentTimelineHasNewer(s,t=>{const n=new Map(t);return n.set(f,o.hasNewer),n}),h.markAgentHistorySynchronized(s,f)):h.applyAgentTimelineResponseState(s,f,{items:c.tail,head:c.head,range:c.cursorChanged?c.cursor??null:u??null,older:c.older,newer:"before"===o.direction?"synced"===l.status&&"available"===l.newer:o.hasNewer,synchronized:p,acknowledgedClientMessageIds:c.acknowledgedClientMessageIds})}function v(t){for(const n of t.result.sideEffects)"catch_up"===n.type&&t.recoverGap(t.agentId,n.cursor);if(t.result.clearInitializing&&S(t.serverId,t.agentId),t.synchronized){s.useCreateFlowStore.getState().clearByAgent({serverId:t.serverId,agentId:t.agentId});const o=n.useSessionStore.getState().sessions[t.serverId],c=o?.agents.get(t.agentId)??o?.agentDetails.get(t.agentId);c&&"idle"===c.turn.phase&&t.drainQueuedAgentMessage(t.agentId)}"resolve"===t.result.initResolution&&(0,c.resolveInitDeferred)(t.initKey)}function y(s){const{serverId:u,payload:p}=s,f=p.agentId,h=(0,c.getInitKey)(u,f),y=n.useSessionStore.getState().sessions[u],w=(0,n.selectAgentTimelineState)(y,f),A=(0,c.getInitDeferred)(h),C="synced"===w.status?w.range??void 0:s.cachedCursor,T=(0,l.processTimelineResponse)({payload:p,currentTail:"cold"===w.status?[]:w.items,currentHead:y?.agentStreamHead.get(f)??[],currentCursor:C,isInitializing:!0===y?.initializingAgents.get(f),hasActiveInitDeferred:Boolean(A),initRequestDirection:A?.requestDirection??"tail",sendingClientMessageIds:(0,o.getSendingClientMessageIds)(y?.messageSubmissions.get(f))});if(T.error)return T.clearInitializing&&S(u,f),"reject"===T.initResolution&&(0,c.rejectInitDeferred)(h,new Error(T.error)),!1;const M=(0,t.isTimelineResumeSnapshotAuthoritative)({direction:p.direction,hasNewer:p.hasNewer,error:p.error});return I({serverId:u,payload:p,result:T,timeline:w,currentCursor:C,synchronized:M}),v({serverId:u,agentId:f,initKey:h,result:T,synchronized:M,recoverGap:s.recoverGap,drainQueuedAgentMessage:s.drainQueuedAgentMessage}),!0}const w=t=>null==t?1e3:Math.min(2*t,3e4);function A(t){return[...new Set(t)].filter(Boolean).sort()}function C(t,n){return t.length===n.length&&t.every((t,s)=>t===n[s])}function T(n){const s=new Map,o=new Map,c=new Map,l=new Map,u=new Set,p=new Map,f=new Set,h=new Set,S=new Map,I=new Set;let v,y=!0,T=!1,M=null,q=!1,R=[],b=[],k=0,D=!1,z=null,E=[];const G=()=>A([...s.values()].flat()),N=t=>{if(0===t.length)return;const n=A([...E,...t]);C(n,E)||(E=n)},O=t=>b.includes(t),H=t=>R.includes(t),U=t=>!q&&T&&H(t)&&O(t),j=(t,n)=>U(t)&&o.get(t)?.generation===n,Q=()=>{for(const t of I)t()},B=t=>{const n=u.delete(t),s=p.delete(t),o=f.delete(t);(n||s||o)&&Q()},_=(t,n)=>{const s=n instanceof Error?n.message:String(n);let o=!1;for(const n of t)f.delete(n)&&(o=!0),u.delete(n)&&(o=!0),p.get(n)!==s&&(p.set(n,s),o=!0);o&&Q()},V=t=>{c.set(t,(c.get(t)??0)+1),o.get(t)?.cancelRetry?.(),o.delete(t),l.delete(t)},F=async(s,c,u,p)=>{if(j(s,c))try{const f=await n.fetchPage(s,u);if(!j(s,c))return;if(f.hasNewer&&f.endCursor){if(p){if(await n.fetchLatestTail(s),!j(s,c))return;return o.set(s,{generation:c,status:"complete"}),void B(s)}return void await F(s,c,(0,t.planTimelineCatchUpAfter)(f.endCursor),!1)}if(f.hasNewer)throw new Error(`Timeline page for ${s} hasNewer without an end cursor`);o.set(s,{generation:c,status:"complete"});const h=l.get(s);if(h)return void P(s,{request:h,supersede:!0});B(s)}catch(t){if(o.get(s)?.generation===c){const l=w(o.get(s)?.retryDelayMs),p=n.schedule(()=>{const t=o.get(s);t?.generation===c&&"error"===t.status&&P(s)},l);o.set(s,{generation:c,status:"error",request:u,cancelRetry:p,retryDelayMs:l}),_([s],t),n.reportError(t)}}finally{W()}},K=t=>{if(h.has(t)||S.has(t))return;const s=n.prepare(t).catch(t=>n.reportError(t)).finally(()=>{S.delete(t),h.add(t);const n=l.get(t);P(t,{request:n,supersede:Boolean(n)})});S.set(t,s)},L=t=>{if(!y||o.has(t))return!1;const n=G();return!n.includes(t)&&n.some(t=>{const n=o.get(t)?.status;return H(t)&&(void 0===n||"running"===n)})},P=(s,u={})=>{const{request:p,supersede:f=!1}=u;if(!U(s))return void(p&&l.set(s,p));if(L(s))return void(p&&l.set(s,p));if(!h.has(s))return p&&l.set(s,p),void K(s);const S=p??(0,t.planTimelineResumeFetch)(n.readCursor(s)),I=o.get(s),v=(y={current:I,request:S,supersede:f}).current?y.supersede?"running"===y.current.status&&(w=y.current.request,A=y.request,w&&A&&w.direction===A.direction&&("after"!==w.direction||"after"!==A.direction||w.cursor.epoch===A.cursor.epoch&&w.cursor.seq===A.cursor.seq))?"keep":"running"===y.current.status&&"tail"===y.current.request?.direction?"keep-and-park":"replace":"running"===y.current.status||"complete"===y.current.status?"keep":"replace":"replace";var y,w,A;if("keep-and-park"===v)return void l.set(s,S);if("keep"===v)return;I?.cancelRetry?.();const C=(c.get(s)??0)+1;c.set(s,C);const T=f||"error"!==I?.status?void 0:I.retryDelayMs;o.set(s,{generation:C,status:"running",request:S,retryDelayMs:T}),l.delete(s),F(s,C,S,void 0===p&&"after"===S.direction)},W=()=>{const t=G(),n=[...t.filter(O),...b.filter(n=>!t.includes(n))];for(const t of n){const n=l.get(t),s=o.get(t);(!s||"complete"===s.status&&n)&&P(t,{request:n,supersede:Boolean(n)})}},$=async()=>{if(q||!T)return;const t=k,s=R;if(D||!C(s,M?.agentIds??b)){D=!1;try{const t=M,o=n.observe(s);M={handle:o,agentIds:s},t?.handle.release().catch(n.reportError),await o.ready}catch(o){if(q||!T||t!==k)return;D=!0,_(s,o),z?.();const c=w(v);return z=n.schedule(()=>{z=null,!q&&T&&k===t&&$()},c),v=c,void n.reportError(o)}!q&&T&&t===k&&(z?.(),z=null,v=void 0,b=s,W())}},x=(t,s={})=>{let o=!1;if(s.resetCatchUpStatus)for(const n of t)u.has(n)||(u.add(n),o=!0),p.delete(n)&&(o=!0),f.delete(n)&&(o=!0);if(C(t,R))o&&Q();else{for(const n of R)t.includes(n)||(V(n),u.delete(n),p.delete(n),f.delete(n));for(const n of t)R.includes(n)||(u.add(n),p.delete(n),f.delete(n),K(n));z?.(),z=null,R=t,n.replaceDemandedAgentIds(R),k+=1,Q(),$()}},J=()=>{x(A([...E,...G()]))};return{subscribe:t=>(I.add(t),()=>I.delete(t)),getAgentTimelineStatus:t=>f.has(t)?"retrying":p.has(t)?"error":!H(t)||u.has(t)?"pending":"ready",getAgentTimelineError:t=>p.get(t)??null,replaceOpenTabAgentIds(t){const n=new Set(t),s=E.filter(t=>n.has(t));C(s,E)||(E=s,J())},replaceVisibleAgentIds(t,n){const o=A(n);0===o.length?s.delete(t):s.set(t,o),N(o),J(),W()},setActive(t){if(y!==t)if(y=t,J(),y){for(const t of G())u.add(t),p.delete(t),P(t,{supersede:!0});Q()}else W()},setConnected(t){if(T!==t)if(T=t,T)k+=1,$();else{x(R,{resetCatchUpStatus:!0}),z?.(),z=null,v=void 0,M?.handle.release().catch(n.reportError),M=null,b=[],k+=1;for(const t of R)V(t)}},recoverGap(n,s){H(n)&&P(n,{request:(0,t.planTimelineCatchUpAfter)({epoch:s.epoch,seq:s.endSeq}),supersede:!0})},dispose(){q=!0,M?.handle.release().catch(n.reportError),M=null,z?.(),z=null,D=!1,v=void 0,s.clear(),k+=1;for(const t of R)V(t);R=[],n.replaceDemandedAgentIds([]),b=[],E=[],h.clear(),S.clear(),u.clear(),p.clear(),f.clear(),Q(),I.clear()},retryVisibleAgentTimeline:t=>{if(!H(t)||f.has(t))return;const n=o.get(t),s=D&&T;if("error"===n?.status||s){if(f.add(t),Q(),"error"===n?.status)return n.cancelRetry?.(),void P(t,{request:n.request,supersede:!0});z?.(),z=null,v=void 0,$()}}}}},3625,[3626,3420,3605,3428,3611,3628,3425]);
|
|
15271
15271
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planTimelineCatchUpAfter=n,e.planTimelineTailFetch=o,e.planTimelineResumeFetch=function(t){return t?n({epoch:t.epoch,seq:t.endSeq}):o()},e.planTimelineOlderFetch=function(n){return{direction:"before",cursor:n,limit:t.TIMELINE_FETCH_PAGE_SIZE,projection:"projected"}},e.planTimelinePromptJump=function(n){const o=Math.floor(t.TIMELINE_FETCH_PAGE_SIZE/2);return{direction:"before",cursor:{epoch:n.epoch,seq:n.seq+o+1},limit:t.TIMELINE_FETCH_PAGE_SIZE,projection:"projected",mergeWindow:!0}},e.isTimelineCatchUpComplete=function(t){if(t.error)return!1;return"after"!==t.direction||!t.hasNewer},e.isTimelineResumeSnapshotAuthoritative=function(t){return!t.error&&"before"!==t.direction&&("tail"===t.direction||!t.hasNewer)};var t=r(d[0]);function n(n){return{direction:"after",cursor:n,limit:t.TIMELINE_FETCH_PAGE_SIZE,projection:"projected"}}function o(){return{direction:"tail",limit:t.TIMELINE_FETCH_PAGE_SIZE,projection:"projected"}}},3626,[3627]);
|
|
15272
15272
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TIMELINE_FETCH_PAGE_SIZE",{enumerable:!0,get:function(){return t}});const t=40},3627,[]);
|
|
15273
15273
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.processTimelineResponse=function(t){const{payload:n,currentTail:s,currentHead:o,currentCursor:c,isInitializing:l,hasActiveInitDeferred:u,initRequestDirection:h,sendingClientMessageIds:v}=t;if(n.error)return{commit:"apply",tail:s,head:o,cursor:c,cursorChanged:!1,older:"unchanged",initResolution:u?"reject":null,clearInitializing:l,error:n.error,sideEffects:[],acknowledgedClientMessageIds:[]};const y=H(n).map(t=>({seq:t.seqStart,seqEnd:t.seqEnd,sourceSeqRanges:t.sourceSeqRanges&&t.sourceSeqRanges.length>0?t.sourceSeqRanges:[{startSeq:t.seqStart,endSeq:t.seqEnd}],event:Object.assign({type:"timeline",provider:t.provider,item:t.item},t.turnId?{turnId:t.turnId}:{}),timestamp:new Date(t.timestamp)})),k=t=>t.map(({event:t,timestamp:s,seqEnd:o})=>({event:t,timestamp:s,timelineCursor:{epoch:n.epoch,seq:o}})),T=p({direction:n.direction,reset:n.reset,epoch:n.epoch,endCursor:n.endCursor,isInitializing:l,hasActiveInitDeferred:u}),E=T.replace,w=[],M=f({direction:n.direction,reset:n.reset,epoch:n.epoch,windowMaxSeq:n.window.maxSeq,pageStartSeq:n.startCursor?.seq??null,currentCursor:c,bootstrapReplace:E}),x="discard"===M.kind;let _;if(x)_={tail:s,head:o,cursor:c,cursorChanged:!1,older:"unchanged",sideEffects:[],acknowledgedClientMessageIds:b({units:y,epoch:n.epoch,currentTail:s,currentHead:o}).filter(t=>v.includes(t))};else if(!0===n.mergeWindow)_=S({timelineUnits:y,payload:n,currentTail:s,currentHead:o,currentCursor:c,toHydratedEvents:k});else if(E||"replace"===M.kind){const t="replace"===M.kind;_=I({timelineUnits:y,payload:n,bootstrapPolicy:t?{replace:!0,catchUpCursor:null}:T,currentTail:s,currentHead:o,sendingClientMessageIds:v,preserveContinuity:q({isResumeReplacement:t,resumePolicy:M,currentEpoch:c?.epoch,responseEpoch:n.epoch,reset:n.reset}),toHydratedEvents:k})}else{_=j({timelineUnits:"append"===M.kind&&c?y.filter(t=>t.seqEnd>c.endSeq):y,payload:n,currentTail:s,currentHead:o,currentCursor:c})}const A=_.tail,U=_.head,O=_.cursor,R=_.cursorChanged;w.push(..._.sideEffects),w.push({type:"flush_pending_updates"});const D=C({hasActiveInitDeferred:u,hasNewer:n.hasNewer,isInitializing:l,initRequestDirection:h,responseDirection:n.direction,reset:n.reset}),N="after"!==n.direction||!n.hasNewer,F=(D||l&&!u)&&N,L=D?"resolve":null;return{commit:x?"discard":"apply",tail:A,head:U,cursor:O,cursorChanged:R,older:_.older,initResolution:L,clearInitializing:F,error:null,sideEffects:w,acknowledgedClientMessageIds:_.acknowledgedClientMessageIds}},e.processAgentStreamEvent=N,e.processAgentStreamEvents=F,e.createAgentStreamReducerQueue=L,e.deriveAgentStreamTurnLiveness=function(t){const n=[];for(const{event:s,timestamp:o}of t)"turn_started"===s.type?n.push({type:"stream_open",turn:{turnId:s.turnId??null,startedAt:o}}):"turn_completed"!==s.type&&"turn_failed"!==s.type&&"turn_canceled"!==s.type||n.push({type:"stream_close",turnId:s.turnId??null});return n},e.createSessionAgentStreamReducerQueue=function(n){const{serverId:s,setAgentStreamState:o,setAgentTimelineCursor:c,recoverTimelineGap:l,onCommitted:u}=n;return L({getSnapshot:n=>{const o=t.useSessionStore.getState().sessions[s],c=(0,t.selectAgentTimelineState)(o,n);return{currentTail:"cold"===c.status?[]:c.items,currentHead:o?.agentStreamHead.get(n)??[],currentCursor:"synced"===c.status?c.range??void 0:void 0,hasAuthoritativeBaseline:"synced"===c.status,isDetached:"synced"===c.status&&"available"===c.newer}},commit:(t,n,l)=>{if((n.changedTail||n.changedHead||n.acknowledgedClientMessageIds.length>0||void 0!==n.taskSnapshot)&&o(s,t,Object.assign({},n.changedTail?{tail:n.tail}:{},n.changedHead?{head:n.head}:{},n.acknowledgedClientMessageIds.length>0?{acknowledgedClientMessageIds:n.acknowledgedClientMessageIds}:{},void 0!==n.taskSnapshot?{taskSnapshot:n.taskSnapshot}:{})),n.cursorChanged&&n.cursor){const o=n.cursor,u=l.at(-1);c(s,n=>{const s=n.get(t);if(s&&u&&"number"==typeof u.seq&&"string"==typeof u.epoch&&s.epoch===u.epoch&&u.seq>=s.startSeq&&u.seq<=s.endSeq)return n;if(s&&s.epoch===o.epoch&&s.startSeq===o.startSeq&&s.endSeq===o.endSeq)return n;const c=new Map(n);return c.set(t,o),c})}u?.(t)},handleSideEffects:(t,n)=>{for(const s of n)"catch_up"===s.type&&l(t,s.cursor)},scheduleFlush:W,cancelFlush:Q})};var t=r(d[0]),n=r(d[1]);const s=48;function o(t,n){const s=[{startSeq:t.startSeq,endSeq:t.endSeq},...t.retainedRanges??[],n].sort((t,n)=>t.startSeq-n.startSeq||t.endSeq-n.endSeq),o=[];for(const t of s){const n=o.at(-1);!n||t.startSeq>n.endSeq+1?o.push(Object.assign({},t)):n.endSeq=Math.max(n.endSeq,t.endSeq)}const c=o.findIndex(n=>n.startSeq<=t.endSeq&&n.endSeq>=t.endSeq),l=o[c];if(!l)return t;const u=o.filter((t,n)=>n!==c);return Object.assign({epoch:t.epoch,startSeq:l.startSeq,endSeq:l.endSeq},u.length>0?{retainedRanges:u}:{})}function c(t,n){if(t.epoch!==n.epoch||t.startSeq!==n.startSeq||t.endSeq!==n.endSeq)return!1;const s=t.retainedRanges??[],o=n.retainedRanges??[];return s.length===o.length&&s.every((t,n)=>t.startSeq===o[n]?.startSeq&&t.endSeq===o[n]?.endSeq&&t.hasOlder===o[n]?.hasOlder)}function l(t,s){const o=(0,n.streamTimelineItemIdentity)(s);return null!==o?(0,n.streamTimelineItemIdentity)(t)===o:"assistant_message"===t.kind&&"assistant_message"===s.kind?t.messageId===s.messageId&&t.text===s.text&&t.timestamp.getTime()===s.timestamp.getTime():"thought"===t.kind&&"thought"===s.kind&&t.text===s.text&&t.timestamp.getTime()===s.timestamp.getTime()}function u(t){let s=t.tail,o=t.head;const c=[],u=[];for(const h of t.hydrated){if("user_message"!==h.kind){const t=s.findIndex(t=>l(t,h)),u=t<0?o.findIndex(t=>l(t,h)):-1,p=t>=0?s:o,f=t>=0?t:u,q=p[f];if(f>=0&&q){const c=[...p];c[f]=(0,n.isAgentToolCallItem)(q)&&(0,n.isAgentToolCallItem)(h)?(0,n.mergeAgentToolCallItem)(q,h.payload.data,h.timestamp,h.timelineCursor):Object.assign({},h,{id:q.id}),t>=0?s=c:o=c;continue}c.push(h);continue}const t=(0,n.upsertUserMessageAcrossStream)({tail:s,head:o,message:h,insert:"none",presentation:"existing"}),p=t.location;p?.matched?(c.push(p.message),void 0!==h.clientMessageId&&u.push(h.clientMessageId),s=t.tail,o=t.head,"tail"===p.lane?s=[...s.slice(0,p.index),...s.slice(p.index+1)]:o=[...o.slice(0,p.index),...o.slice(p.index+1)]):c.push(h)}return{page:c,tail:s,head:o,acknowledgedClientMessageIds:u}}function h({cursor:t,epoch:n,seq:s}){return t?t.epoch!==n?"drop_epoch":s<=t.endSeq?"drop_stale":s===t.endSeq+1?"accept":"gap":"init"}function p({direction:t,reset:n,epoch:s,endCursor:o,isInitializing:c,hasActiveInitDeferred:l}){if(n)return{replace:!0,catchUpCursor:null};return"tail"===t&&c&&l?{replace:!0,catchUpCursor:o?{epoch:s,endSeq:o.seq}:null}:{replace:!1,catchUpCursor:null}}function f(t){return"tail"!==t.direction||t.reset||t.bootstrapReplace||!t.currentCursor?{kind:"not_resume"}:t.currentCursor.epoch!==t.epoch?{kind:"replace",preserveContinuity:!1}:t.windowMaxSeq===t.currentCursor.endSeq?{kind:"discard"}:t.windowMaxSeq<t.currentCursor.endSeq?{kind:"replace",preserveContinuity:!1}:null!==t.pageStartSeq&&t.pageStartSeq<=t.currentCursor.endSeq+1?{kind:"append"}:{kind:"replace",preserveContinuity:!0}}function q(t){return t.isResumeReplacement&&"replace"===t.resumePolicy.kind?t.resumePolicy.preserveContinuity:t.currentEpoch===t.responseEpoch||!t.reset}function S(t){const{timelineUnits:s,payload:l,currentTail:h,currentHead:p,currentCursor:f,toHydratedEvents:q}=t;if(!l.startCursor||!l.endCursor||f?.epoch!==l.epoch)return{tail:h,head:p,cursor:f,cursorChanged:!1,older:"unchanged",sideEffects:[],acknowledgedClientMessageIds:[]};const S=l.startCursor.seq,C=l.endCursor.seq,I=_({tail:h,head:p,units:s,epoch:l.epoch,currentEndSeq:f.endSeq}),v=I.tail.filter(t=>{const n=t.timelineCursor;return n?.epoch!==l.epoch||n.seq<S||n.seq>C}),y=I.head,k=new Set([...v,...y].map(t=>t.id)),T=u({hydrated:(0,n.hydrateStreamState)(q(s.filter(t=>!I.reconciledUnits.has(t))),{source:"canonical",reservedItemIds:k}),tail:v,head:y}),E=[...T.tail,...T.page].map((t,n)=>({item:t,order:n})).sort((t,n)=>(t.item.timelineCursor?.seq??Number.POSITIVE_INFINITY)-(n.item.timelineCursor?.seq??Number.POSITIVE_INFINITY)||t.order-n.order).map(({item:t})=>t),w=o(f,{startSeq:S,endSeq:C,hasOlder:l.hasOlder}),M=Math.min(f.startSeq,...(f.retainedRanges??[]).map(t=>t.startSeq));let x="unchanged";return S<=M&&(x=l.hasOlder?"available":"none"),{tail:E,head:T.head,cursor:w,cursorChanged:!c(f,w),older:x,sideEffects:[],acknowledgedClientMessageIds:T.acknowledgedClientMessageIds}}function C({hasActiveInitDeferred:t,hasNewer:n,isInitializing:s,initRequestDirection:o,responseDirection:c,reset:l}){return!(!t||!s)&&(!!l||("after"!==c||!n)&&c===o)}function I(t){const{timelineUnits:s,payload:o,bootstrapPolicy:c,currentTail:l,currentHead:u,sendingClientMessageIds:h,preserveContinuity:p,toHydratedEvents:f}=t,q=(0,n.hydrateStreamState)(f(s),{source:"canonical"}),{tail:S,head:C,acknowledgedClientMessageIds:I}=(0,n.replaceWithCanonicalStream)({canonical:q,previousTail:l,previousHead:u,sendingClientMessageIds:h,preserveContinuity:p,canonicalCoverage:{epoch:o.epoch,endSeq:o.endCursor?.seq??null}}),v=o.startCursor&&o.endCursor?{epoch:o.epoch,startSeq:o.startCursor.seq,endSeq:o.endCursor.seq}:null,y=[];return c.catchUpCursor&&y.push({type:"catch_up",cursor:c.catchUpCursor}),{tail:S,head:C,cursor:v,cursorChanged:!0,older:o.hasOlder?"available":"none",sideEffects:y,acknowledgedClientMessageIds:I}}function v(t){const{timelineUnits:n,payload:s,currentCursor:o}=t,c=n[0],l=n[n.length-1],u=s.startCursor?.seq??c?.seq,h=s.endCursor?.seq??l?.seqEnd;return void 0===u||void 0===h?{acceptedUnits:[],cursor:o,gapCursor:null}:o?o.epoch!==s.epoch?{acceptedUnits:[],cursor:o,gapCursor:null}:(!s.startCursor||!s.endCursor)&&u<=o.endSeq&&h>o.endSeq?{acceptedUnits:[],cursor:o,gapCursor:{epoch:o.epoch,endSeq:o.endSeq}}:h<=o.endSeq?{acceptedUnits:[],cursor:o,gapCursor:null}:u>o.endSeq+1?{acceptedUnits:[],cursor:o,gapCursor:{epoch:o.epoch,endSeq:o.endSeq}}:{acceptedUnits:n,cursor:Object.assign({},o,{endSeq:h}),gapCursor:null}:{acceptedUnits:n,cursor:{epoch:s.epoch,startSeq:u,endSeq:h},gapCursor:null}}function y(t){const{timelineUnits:n,payload:s,currentCursor:c}=t;if(!c||c.epoch!==s.epoch)return{acceptedUnits:[],cursor:c,gapCursor:null};const l=n[0],u=n[n.length-1],h=s.startCursor?.seq??l?.seq,p=s.endCursor?.seq??u?.seqEnd;return void 0===h||void 0===p||p!==c.startSeq-1?{acceptedUnits:[],cursor:c,gapCursor:null}:{acceptedUnits:n,cursor:o(c,{startSeq:h,endSeq:p,hasOlder:s.hasOlder}),gapCursor:null}}function k(t,s){if(0===t.length)return s;if(0===s.length)return t;const o=[];let c=s;for(const s of t){if("user_message"!==s.kind){o.push(s);continue}const t=(0,n.upsertUserMessageAcrossStream)({tail:c,head:[],message:s,insert:"prepend-tail",presentation:"existing"});t.location?.matched?(o.push(t.location.message),c=[...t.tail.slice(0,t.location.index),...t.tail.slice(t.location.index+1)]):o.push(s)}if(s=c,0===(t=o).length)return s;const l=t.at(-1),u=s[0],h=T(t,s);if(h)return h;if("assistant_message"!==l?.kind||"assistant_message"!==u?.kind)return[...t,...s];const p=Object.assign({},u,{text:`${l.text}${u.text}`});return void 0===p.messageId&&void 0!==l.messageId&&(p.messageId=l.messageId),[...t.slice(0,-1),p,...s.slice(1)]}function T(t,s){const o=t.at(-1),c=s[0];if(!o||!c)return null;const l=(0,n.streamTimelineItemIdentity)(o);return null===l||l!==(0,n.streamTimelineItemIdentity)(c)?null:"plugin"===o.kind&&"plugin"===c.kind?[...t.slice(0,-1),c,...s.slice(1)]:(0,n.isAgentToolCallItem)(o)&&(0,n.isAgentToolCallItem)(c)?[...t.slice(0,-1),(0,n.mergeAgentToolCallItem)(o,c.payload.data,c.timestamp),...s.slice(1)]:null}function E(t){const n=[],s=[];for(const o of t.currentTail){const c=o.timelineCursor;c?.epoch!==t.epoch?s.push(o):c.seq<t.startSeq?n.push(o):c.seq>t.endSeq&&s.push(o)}return[...n,...k(t.page,s)]}function w(t){const{head:n,event:s,timestamp:o,timelineCursor:c}=t;if("timeline"!==s.type||"assistant_message"!==s.item.type)return null;const l=n.findLastIndex(t=>"assistant_message"===t.kind),u=n[l];if(!u||"assistant_message"!==u.kind)return null;if(!s.item.text.startsWith(u.text))return null;const h=[...n];return h[l]=Object.assign({},u,{text:s.item.text,timestamp:o,timelineCursor:c}),h}function M(t){const{unit:n}=t;if("timeline"!==n.event.type||"assistant_message"!==n.event.item.type||!n.sourceSeqRanges.some(n=>n.startSeq<=t.currentEndSeq&&n.endSeq>t.currentEndSeq))return{tail:t.tail,head:t.head,reconciled:!1};const s=n.event.item.text,o=n.event.item.messageId,c=t=>"assistant_message"===t.kind&&(o&&t.messageId?t.messageId===o:s.startsWith(t.text)),l=t=>{const n=t.findLastIndex(c),s=t[n];return"assistant_message"===s?.kind?{current:s,index:n}:null},u=l(t.head),h=u?null:l(t.tail),p=u??h;if(!p)return{tail:t.tail,head:t.head,reconciled:!1};const f=o??p.current.messageId,q=Object.assign({kind:"assistant_message",id:p.current.id},void 0!==f?{messageId:f}:{},{text:s,timestamp:n.timestamp,timelineCursor:{epoch:t.epoch,seq:n.seqEnd}}),S=(t,n)=>{const s=[...t];return s[n]=q,s};return u?{tail:t.tail,head:S(t.head,u.index),reconciled:!0}:{tail:S(t.tail,p.index),head:t.head,reconciled:!0}}function x(t){const{unit:n}=t;if("timeline"!==n.event.type||"reasoning"!==n.event.item.type||!n.sourceSeqRanges.some(n=>n.startSeq<=t.currentEndSeq&&n.endSeq>t.currentEndSeq))return{tail:t.tail,head:t.head,reconciled:!1};const s=n.event.item.text,o=t=>{const o=t.findLastIndex(t=>"thought"===t.kind&&s.startsWith(t.text)),c=t[o];if(!c||"thought"!==c.kind)return null;const l=[...t];return l[o]=Object.assign({},c,{text:s,timestamp:n.timestamp,status:"loading"}),l},c=o(t.head);if(c)return{tail:t.tail,head:c,reconciled:!0};const l=o(t.tail);return l?{tail:l,head:t.head,reconciled:!0}:{tail:t.tail,head:t.head,reconciled:!1}}function _(t){let n=t.tail,s=t.head;const o=new Set;if(void 0===t.currentEndSeq)return{tail:n,head:s,reconciledUnits:o};for(const c of t.units){let l=M({tail:n,head:s,unit:c,epoch:t.epoch,currentEndSeq:t.currentEndSeq});l.reconciled||(l=x({tail:n,head:s,unit:c,currentEndSeq:t.currentEndSeq})),n=l.tail,s=l.head,l.reconciled&&o.add(c)}return{tail:n,head:s,reconciledUnits:o}}function A(t){const{event:s,timestamp:o,seqEnd:c}=t.unit,l={epoch:t.epoch,seq:c};if("timeline"===s.type&&"user_message"===s.item.type){const c=(0,n.applyStreamEvent)({tail:t.tail,head:t.head,event:s,timestamp:o,source:"canonical",timelineCursor:l});return{tail:c.tail,head:c.head,acknowledgedClientMessageIds:c.acknowledgedClientMessageIds??[]}}if(0===t.head.length)return{tail:(0,n.reduceStreamUpdate)(t.tail,s,o,{source:"canonical",timelineCursor:l}),head:t.head,acknowledgedClientMessageIds:[]};const u=w({head:t.head,event:s,timestamp:o,timelineCursor:l});if(u)return{tail:t.tail,head:u,acknowledgedClientMessageIds:[]};const h=t.head.findLast(t=>"assistant_message"===t.kind);if("timeline"===s.type&&"assistant_message"===s.item.type&&void 0!==s.item.messageId&&s.item.messageId!==h?.messageId)return{tail:(0,n.flushHeadToTail)(t.tail,t.head),head:(0,n.reduceStreamUpdate)([],s,o,{source:"canonical",timelineCursor:l}),acknowledgedClientMessageIds:[]};const p=(0,n.applyStreamEvent)({tail:t.tail,head:t.head,event:s,timestamp:o,source:"canonical",timelineCursor:l});return{tail:p.tail,head:p.head,acknowledgedClientMessageIds:p.acknowledgedClientMessageIds??[]}}function U(t){const n=_({tail:t.currentTail,head:t.currentHead,units:t.units,epoch:t.epoch,currentEndSeq:t.currentEndSeq});let s=n.tail,o=n.head;for(const c of t.units){if(n.reconciledUnits.has(c))continue;const l=A({tail:s,head:o,unit:c,epoch:t.epoch});s=l.tail,o=l.head}return{tail:s,head:o,acknowledgedClientMessageIds:b({units:t.units,epoch:t.epoch,currentTail:t.currentTail,currentHead:t.currentHead})}}function b(t){let n=t.currentTail,s=t.currentHead;const o=new Set;for(const c of t.units){if("timeline"!==c.event.type||"user_message"!==c.event.item.type)continue;const l=A({tail:n,head:s,unit:c,epoch:t.epoch});n=l.tail,s=l.head;for(const t of l.acknowledgedClientMessageIds)o.add(t)}return[...o]}function H(t){if("before"!==t.direction||"projected"!==t.projection||!t.startCursor||!t.endCursor)return t.entries;const n=t.startCursor.seq,s=t.endCursor.seq;return t.entries.filter(t=>t.seqStart>=n&&t.seqStart<=s)}function O(t){const{payload:n,cursor:s,currentCursor:o}=t;if("before"!==n.direction||!s||!o||s.startSeq===o.startSeq)return"unchanged";const c=o.retainedRanges?.find(t=>t.startSeq===s.startSeq);return c?.hasOlder??n.hasOlder?"available":"none"}function R(t){const{acceptedUnits:s,payload:o,currentTail:c,currentHead:l,currentCursor:u}=t;if(0===s.length)return{tail:c,head:l,acknowledgedClientMessageIds:[]};if("before"!==o.direction)return U({units:s,epoch:o.epoch,currentTail:c,currentHead:l,currentEndSeq:u?.endSeq});return{tail:E({page:(0,n.hydrateStreamState)(s.map(({event:t,timestamp:n,seqEnd:s})=>({event:t,timestamp:n,timelineCursor:{epoch:o.epoch,seq:s}})),{source:"canonical",reservedItemIds:new Set(c.map(t=>t.id))}),currentTail:c,epoch:o.epoch,startSeq:o.startCursor?.seq??s[0]?.seq??0,endSeq:o.endCursor?.seq??s.at(-1)?.seqEnd??0}),head:l,acknowledgedClientMessageIds:[]}}function j(t){const{timelineUnits:n,payload:s,currentTail:o,currentHead:l,currentCursor:u}=t;let h=u,p=!1;const f=[];if(0===n.length&&"before"!==s.direction)return{tail:o,head:l,cursor:h,cursorChanged:p,older:"unchanged",sideEffects:f,acknowledgedClientMessageIds:[]};const{acceptedUnits:q,cursor:S,gapCursor:C}="before"===s.direction?y({timelineUnits:n,payload:s,currentCursor:u}):v({timelineUnits:n,payload:s,currentCursor:u}),I=R({acceptedUnits:q,payload:s,currentTail:o,currentHead:l,currentCursor:u});return!S||u&&c(u,S)||(h=S,p=!0),C&&f.push({type:"catch_up",cursor:C}),{tail:I.tail,head:I.head,cursor:h,cursorChanged:p,older:O({payload:s,cursor:S,currentCursor:u}),sideEffects:f,acknowledgedClientMessageIds:I.acknowledgedClientMessageIds}}function D(t){const{event:n,seq:s,epoch:o,currentCursor:c,hasAuthoritativeBaseline:l}=t,u={shouldApplyStreamEvent:!0,nextTimelineCursor:null,cursorChanged:!1,resetLiveTimeline:!1,sideEffects:[]};if("timeline"!==n.type||"number"!=typeof s||"string"!=typeof o)return u;if(!l)return u;const p=h({cursor:c?{epoch:c.epoch,endSeq:c.endSeq}:null,epoch:o,seq:s});return"init"===p?Object.assign({},u,{nextTimelineCursor:{epoch:o,startSeq:s,endSeq:s},cursorChanged:!0}):"accept"===p?Object.assign({},u,{nextTimelineCursor:Object.assign({},c??{epoch:o,startSeq:s,endSeq:s},{epoch:o,endSeq:s}),cursorChanged:!0}):"gap"===p?Object.assign({},u,{shouldApplyStreamEvent:!1,sideEffects:c?[{type:"catch_up",cursor:{epoch:c.epoch,endSeq:c.endSeq}}]:[]}):"drop_epoch"===p&&1===s?Object.assign({},u,{nextTimelineCursor:{epoch:o,startSeq:s,endSeq:s},cursorChanged:!0,resetLiveTimeline:!0}):Object.assign({},u,{shouldApplyStreamEvent:!1})}function N(t){const{event:s,seq:o,epoch:c,currentTail:l,currentHead:u,currentCursor:h,timestamp:p,hasAuthoritativeBaseline:f=!0}=t,q=D({event:s,seq:o,epoch:c,currentCursor:h,hasAuthoritativeBaseline:f}),S="timeline"===s.type&&void 0!==o&&void 0!==c?{epoch:c,seq:o}:void 0;let C;if(q.shouldApplyStreamEvent)if(f)C=(0,n.applyStreamEvent)({tail:q.resetLiveTimeline?[]:l,head:q.resetLiveTimeline?[]:u,event:s,timestamp:p,source:"live",timelineCursor:S});else if("timeline"===s.type&&"user_message"===s.item.type)C=(0,n.applyStreamEvent)({tail:l,head:u,event:s,timestamp:p,source:"live",timelineCursor:S,unmatchedUserMessageInsert:"head"});else{const t=(0,n.applyStreamEvent)({tail:u,head:[],event:s,timestamp:p,source:"live",timelineCursor:S});C={tail:l,head:[...t.tail,...t.head],changedTail:!1,changedHead:t.changedTail||t.changedHead}}else C={tail:l,head:u,changedTail:!1,changedHead:!1};const{tail:I,head:v,changedTail:y,changedHead:k}=C;return Object.assign({tail:I,head:v,changedTail:y,changedHead:k,cursor:q.nextTimelineCursor,cursorChanged:q.cursorChanged,acknowledgedClientMessageIds:C.acknowledgedClientMessageIds??[]},q.shouldApplyStreamEvent&&"timeline"===s.type&&"todo"===s.item.type?{taskSnapshot:s.item.items}:{},{sideEffects:q.sideEffects})}function F(t){if(t.isDetached)return{tail:t.currentTail,head:t.currentHead,changedTail:!1,changedHead:!1,cursor:t.currentCursor??null,cursorChanged:!1,acknowledgedClientMessageIds:[],sideEffects:[]};let n,s=t.currentTail,o=t.currentHead,c=t.currentCursor,l=!1,u=!1,h=!1;const p=new Set,f=[];for(const q of t.events){const S=N({event:q.event,seq:q.seq,epoch:q.epoch,currentTail:s,currentHead:o,currentCursor:c,hasAuthoritativeBaseline:t.hasAuthoritativeBaseline,timestamp:q.timestamp});s=S.tail,o=S.head,l=l||S.changedTail,u=u||S.changedHead,f.push(...S.sideEffects);for(const t of S.acknowledgedClientMessageIds)p.add(t);void 0!==S.taskSnapshot&&(n=S.taskSnapshot),S.cursorChanged&&(c=S.cursor??void 0,h=!0)}return Object.assign({tail:s,head:o,changedTail:l,changedHead:u,cursor:c??null,cursorChanged:h,acknowledgedClientMessageIds:[...p]},void 0!==n?{taskSnapshot:n}:{},{sideEffects:f})}function L(t){const n=new Map;let s=null;const o=()=>{null!==s&&(t.cancelFlush(s),s=null)},c=s=>{const c=n.get(s);if(!c||0===c.length)return;n.delete(s),0===n.size&&o();const l=F(Object.assign({events:c},t.getSnapshot(s)));t.commit(s,l,c),l.sideEffects.length>0&&t.handleSideEffects(s,l.sideEffects)},l=()=>{const t=Array.from(n.keys());for(const n of t)c(n)};return{enqueue(o,c){const u=n.get(o);u?u.push(c):n.set(o,[c]),null===s&&(s=t.scheduleFlush(()=>{s=null,l()}))},flush:l,flushAgent:c,dispose(t){o(),t?.flush?l():n.clear()}}}const z=new Map;let P=1;function B(t){null!==t.frameId&&cancelAnimationFrame(t.frameId),clearTimeout(t.timerId)}function W(t){const n=P;P+=1;const o=()=>{const s=z.get(n);s&&(z.delete(n),B(s),t())},c=setTimeout(o,s),l="function"==typeof requestAnimationFrame?requestAnimationFrame(o):null;return z.set(n,{frameId:l,timerId:c}),n}function Q(t){const n=z.get(t);n&&(z.delete(t),B(n))}},3628,[3420,3425]);
|
|
@@ -16160,7 +16160,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
16160
16160
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDraftAgentFeatures=function(p){const v=(0,t.c)(62),{t:F}=(0,u.useTranslation)(),{serverId:V,provider:y,cwd:P,modeId:w,modelId:b,thinkingOptionId:h,initialFeatureValues:I}=p;let O;v[0]!==I?(O=()=>I??{},v[0]=I,v[1]=O):O=v[1];const[_,j]=(0,s.useState)(O),k=(0,o.useHostRuntimeClient)(V??""),E=(0,o.useHostRuntimeIsConnected)(V??""),{preferences:L,updatePreferences:D}=(0,l.useFormPreferences)();let R;v[2]!==P?(R=P?.trim()||"",v[2]=P,v[3]=R):R=v[3];const q=R,A=y??null,C=(0,s.useRef)(A);let H;v[4]!==L.providerPreferences||v[5]!==y?(H=y?L.providerPreferences?.[y]?.featureValues??{}:{},v[4]=L.providerPreferences,v[5]=y,v[6]=H):H=v[6];const S=H;let T;e:{if(!A||!q){T=null;break e}let t,s,n,u;v[7]!==w?(t=w?{modeId:w}:{},v[7]=w,v[8]=t):t=v[8],v[9]!==b?(s=b?{model:b}:{},v[9]=b,v[10]=s):s=v[10],v[11]!==h?(n=h?{thinkingOptionId:h}:{},v[11]=h,v[12]=n):n=v[12],v[13]!==q||v[14]!==A||v[15]!==t||v[16]!==s||v[17]!==n?(u=Object.assign({provider:A,cwd:q},t,s,n),v[13]=q,v[14]=A,v[15]=t,v[16]=s,v[17]=n,v[18]=u):u=v[18],T=u}const B=T,K=V??null,M=q||null,Q=w??null,x=b??null,z=h??null;let G;v[19]!==A||v[20]!==K||v[21]!==M||v[22]!==Q||v[23]!==x||v[24]!==z?(G=["providerFeatures",K,A,M,Q,x,z],v[19]=A,v[20]=K,v[21]=M,v[22]=Q,v[23]=x,v[24]=z,v[25]=G):G=v[25];const J=Boolean(V&&k&&E&&B);let N,U;v[26]!==k||v[27]!==B||v[28]!==F?(N=async()=>{if(!k||!B)throw new Error(F("workspace.terminal.hostDisconnected"));const t=await k.listProviderFeatures(B);if(t.error)throw new Error(t.error);return t.features??[]},v[26]=k,v[27]=B,v[28]=F,v[29]=N):N=v[29];v[30]!==J||v[31]!==N||v[32]!==G?(U={queryKey:G,enabled:J,staleTime:3e5,queryFn:N},v[30]=J,v[31]=N,v[32]=G,v[33]=U):U=v[33];const W=(0,n.useQuery)(U),X=W.data;let Y;v[34]!==X?(Y=X??[],v[34]=X,v[35]=Y):Y=v[35];const Z=Y;let $;v[36]!==Z||v[37]!==_||v[38]!==S?($=(0,c.resolveFeatureValues)({features:Z,persistedFeatureValues:S,localFeatureValues:_}),v[36]=Z,v[37]=_,v[38]=S,v[39]=$):$=v[39];const ee=$;let re;v[40]!==Z||v[41]!==ee?(re=(0,c.applyFeatureValues)(Z,ee),v[40]=Z,v[41]=ee,v[42]=re):re=v[42];const te=re;let se,ne,ue,oe,ae;v[43]!==A?(se=()=>{const t=C.current;C.current=A,null!==t&&t!==A&&j({})},ne=[A],v[43]=A,v[44]=se,v[45]=ne):(se=v[44],ne=v[45]);(0,s.useEffect)(se,ne),v[46]!==Z||v[47]!==X||v[48]!==_?(ue=()=>{if(void 0===X)return;const t=(0,c.pruneFeatureValues)(_,Z);t!==_&&j(t)},oe=[Z,X,_],v[46]=Z,v[47]=X,v[48]=_,v[49]=ue,v[50]=oe):(ue=v[49],oe=v[50]);(0,s.useEffect)(ue,oe),v[51]!==ee?(ae=Object.keys(ee).length>0?ee:void 0,v[51]=ee,v[52]=ae):ae=v[52];const le=ae;let ie;v[53]!==y||v[54]!==D?(ie=(t,s)=>{j(n=>Object.is(n[t],s)?n:Object.assign({},n,{[t]:s})),y&&D(n=>(0,l.mergeProviderPreferences)({preferences:n,provider:y,updates:{featureValues:{[t]:s}}})).catch(f)},v[53]=y,v[54]=D,v[55]=ie):ie=v[55];const ce=ie;let de;v[56]===Symbol.for("react.memo_cache_sentinel")?(de=t=>{j(t)},v[56]=de):de=v[56];const fe=de;let pe;v[57]!==le||v[58]!==te||v[59]!==W.isLoading||v[60]!==ce?(pe={features:te,featureValues:le,isLoading:W.isLoading,setFeatureValue:ce,applyProfileFeatureValues:fe},v[57]=le,v[58]=te,v[59]=W.isLoading,v[60]=ce,v[61]=pe):pe=v[61];return pe};var t=r(d[0]),s=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),l=r(d[5]),c=r(d[6]);function f(t){console.warn("[useDraftAgentFeatures] persist feature preference failed",t)}},4505,[453,36,799,853,3466,4383,4377]);
|
|
16161
16161
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.resolveDraftKey=function(o){if("function"==typeof o.draftKey)return o.draftKey({selectedServerId:o.selectedServerId});return o.draftKey},e.buildDraftAgentControls=function(o){const{formState:t,features:n,onSetFeature:l,onApplyAgentProfile:s,onDropdownClose:c}=o;return{providerDefinitions:t.providerDefinitions,selectedProvider:t.selectedProvider,modeOptions:t.modeOptions,selectedMode:t.selectedMode,onSelectMode:t.setModeFromUser,models:t.availableModels,selectedModel:t.selectedModel,onSelectModel:t.setModelFromUser,isModelLoading:t.isModelLoading,modelSelectorProviders:t.modelSelectorProviders,isAllModelsLoading:t.isAllModelsLoading,onSelectProviderAndModel:t.setProviderAndModelFromUser,thinkingOptions:t.availableThinkingOptions,selectedThinkingOptionId:t.selectedThinkingOptionId,onSelectThinkingOption:t.setThinkingOptionFromUser,onApplyAgentProfile:s,features:n,onSetFeature:l,onDropdownClose:c,onModelSelectorOpen:t.refetchProviderModelsIfStale,onRetryModelProvider:t.refreshProviderModels,isRetryingModelProvider:t.isProviderModelsRefreshing,modelSelectorServerId:t.selectedServerId}},e.hasDraftContent=function(o){return o.text.length>0||o.attachments.length>0},e.areAttachmentsEqual=function(o){if(o.left.length!==o.right.length)return!1;return o.left.every((t,n)=>{const l=o.right[n];return JSON.stringify(t)===JSON.stringify(l)})}},4506,[]);
|
|
16162
16162
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WorkspaceShortcutTargetsSubscriber=function(n){const f=(0,t.c)(8),{enabled:h}=n,{shortcutModel:l}=(0,u.useSidebarModel)(),b=(0,c.useKeyboardShortcutsStore)(o);let S,T,_,p;f[0]!==h||f[1]!==b||f[2]!==l.shortcutTargets?(S=()=>{b(h?l.shortcutTargets:[])},T=[h,b,l.shortcutTargets],f[0]=h,f[1]=b,f[2]=l.shortcutTargets,f[3]=S,f[4]=T):(S=f[3],T=f[4]);(0,s.useEffect)(S,T),f[5]!==b?(_=()=>()=>{b([])},p=[b],f[5]=b,f[6]=_,f[7]=p):(_=f[6],p=f[7]);return(0,s.useEffect)(_,p),null};var t=r(d[0]),s=r(d[1]),u=r(d[2]),c=r(d[3]);function o(t){return t.setSidebarShortcutWorkspaceTargets}},4507,[453,36,4085,3755]);
|
|
16163
|
-
__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SessionProvider=function(e){const n=(0,t.c)(2);let s;n[0]!==e?(s=(0,z.jsx)(x,Object.assign({},e)),n[0]=e,n[1]=s):s=n[1];return s};var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),i=(e=o)&&e.__esModule?e:{default:e},c=r(d[4]),u=r(d[5]),l=r(d[6]),p=r(d[7]),f=r(d[8]),y=r(d[9]),S=r(d[10]),v=r(d[11]),h=r(d[12]),I=r(d[13]),b=r(d[14]),_=r(d[15]),A=r(d[16]),k=r(d[17]),w=r(d[18]),T=r(d[19]),M=r(d[20]),q=r(d[21]),E=r(d[22]),P=r(d[23]),C=r(d[24]),R=r(d[25]),O=r(d[26]),V=r(d[27]),F=r(d[28]),z=r(d[29]);function H(e){const t=e.map(e=>{return t=e.audio,s.Buffer.from(t,"base64");var t}),n=t.reduce((e,t)=>e+t.length,0),o=new Uint8Array(n);let i=0;for(const e of t)o.set(e,i),i+=e.length;const c=e[0]?.format??"pcm";let u;u="pcm"===c?"audio/pcm;rate=24000;bits=16":"mp3"===c?"audio/mpeg":`audio/${c}`;const l=o.slice();return{size:l.byteLength,type:u,arrayBuffer:async()=>l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}}const L=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];if("assistant_message"===n.kind)return n.text}return null},j=(e,t)=>{if(!e)return null;let n=null;for(const s of e.pendingPermissions.values())s.agentId===t&&(n=s.request);if(n)return n;const s=e.agents.get(t)?.pendingPermissions;return s&&s.length>0?s[s.length-1]:null};function x(e){const n=(0,t.c)(4),{children:s,serverId:o,client:i}=e;let c;return n[0]!==s||n[1]!==i||n[2]!==o?(c=(0,z.jsx)(N,{serverId:o,client:i,children:s}),n[0]=s,n[1]=i,n[2]=o,n[3]=c):c=n[3],c}function N({children:e,serverId:t,client:s}){const{t:o}=(0,l.useTranslation)(),z=(0,k.useVoiceRuntimeOptional)(),x=(0,k.useVoiceAudioEngineOptional)(),N=(0,u.useQueryClient)(),U=(0,A.useHostRuntimeIsConnected)(t),D=(0,C.useToast)(),$=(0,w.useSessionStore)(e=>e.setIsPlayingAudio),B=(0,w.useSessionStore)(e=>e.setAgentStreamTail),K=(0,w.useSessionStore)(e=>e.setAgentStreamHead),W=(0,w.useSessionStore)(e=>e.clearAgentStreamHead),Q=(0,w.useSessionStore)(e=>e.setInitializingAgents),G=(0,w.useSessionStore)(e=>e.setAgents),J=(0,w.useSessionStore)(e=>e.flushAgentLastActivity),X=(0,w.useSessionStore)(e=>e.setPendingPermissions),Y=(0,w.useSessionStore)(e=>e.updateSessionServerInfo),Z=(0,w.useSessionStore)(e=>e.setViewedTimelineSync),ee=(0,T.useWorkspaceSetupStore)(e=>e.upsertProgress),te=(0,w.useSessionStore)(e=>e.sessions[t]?.focusedAgentId??null),ne=(0,w.useSessionStore)(e=>e.sessions[t]?.focusedTerminalId??null),se=((0,n.useRef)(null),(0,n.useRef)(new Map)),re=(0,n.useRef)(i.default.currentState),ae=(0,n.useRef)(null),oe=(0,n.useRef)(new Map),ie=(0,n.useRef)(new Set),ce=(0,f.useAppVisible)();(0,n.useEffect)(()=>{const e=i.default.addEventListener("change",e=>{re.current=e});return()=>{e.remove()}},[]),(0,n.useEffect)(()=>{ae.current?.setActive(ce)},[ce]),(0,p.useClientActivity)({client:s,focusedAgentId:te,focusedTerminalId:ne}),(0,n.useEffect)(()=>(0,y.startPushNotifications)({client:s,serverId:t}),[s,t]);const de=(0,n.useCallback)(e=>{const n=re.current,s=w.useSessionStore.getState().sessions[t],o=s?.focusedAgentId??null;if("error"===e.reason)return;if(!(!(0,q.getIsAppActivelyVisible)(n)||o!==e.agentId))return;const i=new Date(e.timestamp).getTime(),c=se.current.get(e.agentId);if(c&&c>=i)return;se.current.set(e.agentId,i);const u=s?.agentStreamHead.get(e.agentId)??[],l=s?.agentStreamTail.get(e.agentId)??[],p=L(u)??L(l),f=j(s,e.agentId),y=s?.agents?.get(e.agentId)?.workspaceId,S=(v={notification:e.notification,reason:e.reason,serverId:t,workspaceId:y,agentId:e.agentId,assistantMessage:p,permissionRequest:f}).notification?v.notification.data.workspaceId?v.notification:null:v.workspaceId?(0,_.buildAgentAttentionNotificationPayload)({reason:v.reason,serverId:v.serverId,workspaceId:v.workspaceId,agentId:v.agentId,assistantMessage:"finished"===v.reason?v.assistantMessage:null,permissionRequest:"permission"===v.reason?v.permissionRequest:null}):null;var v;S&&(0,M.sendOsNotification)({title:S.title,body:S.body,data:S.data})},[t]);(0,n.useEffect)(()=>{const e=s.getLastServerInfoMessage();e&&Y(t,Object.assign({serverId:e.serverId,hostname:e.hostname,version:e.version},void 0!==e.desktopManaged?{desktopManaged:e.desktopManaged}:{},e.capabilities?{capabilities:e.capabilities}:{},e.features?{features:e.features}:{}))},[s,t,Y]),(0,n.useEffect)(()=>{const e=z?.registerSession({serverId:t,setVoiceMode:async(e,t)=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.setVoiceMode(e,t)},sendVoiceAudioChunk:async(e,t)=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.sendVoiceAudioChunk(e,t)},audioPlayed:async e=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.audioPlayed(e)},abortRequest:async()=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.abortRequest()},setAssistantAudioPlaying:e=>{$(t,e)}});return()=>e?.()},[s,t,$,o,z]),(0,n.useEffect)(()=>{z?.updateSessionConnection(t,U)},[U,t,z]),(0,n.useEffect)(()=>{U||(J(),Q(t,new Map))},[J,t,U,Q]);const ue=(0,n.useCallback)(e=>{ee({serverId:t,payload:e})},[t,ee]);(0,n.useEffect)(()=>{const e=(0,S.createSetAgentInitializing)(t,Q),n=e=>{if("agent_stream"!==e.type)return;const{agentId:n,event:s,timestamp:i,seq:c,epoch:u}=e.payload,l=new Date(i),p=s;"turn_started"!==s.type&&"turn_completed"!==s.type&&"turn_failed"!==s.type&&"turn_canceled"!==s.type||z?.onTurnEvent(t,n,s.type);const f=(0,v.deriveAgentStreamTurnLiveness)([{event:p,seq:c,epoch:u,timestamp:l}]);f.length>0&&(0,A.getHostRuntimeStore)().applyAgentTurnLiveness(t,n,f),o.enqueueStreamEvent(n,{event:p,seq:c,epoch:u,timestamp:l})},o=(0,A.getHostRuntimeStore)().createViewedTimelineOwner(t,{observe:e=>{const o=s.observeTimeline(e);return o.subscribe({snapshot:()=>{},update:e=>{var s;"agent_stream"===e.type?n(e):"agent.timeline.replacement"===e.type&&("agent.timeline.replacement"===(s=e).type&&(0,I.requestTimelineReplacement)({fetchAgentTimeline:(e,n)=>(0,A.getHostRuntimeStore)().fetchAgentTimeline(t,e,n)},s.payload.agentId).catch(e=>{console.warn("[Session] timeline replacement refresh failed",{serverId:t,error:e})}))}}),o},readCursor:e=>{const n=(0,w.selectAgentTimelineState)(w.useSessionStore.getState().sessions[t],e);return"synced"===n.status&&n.range?{epoch:n.range.epoch,endSeq:n.range.endSeq}:void 0},fetchPage:async(n,s)=>{const o=w.useSessionStore.getState().sessions[t],i=(0,E.getInitKey)(t,n),c="synced"!==(0,w.selectAgentTimelineState)(o,n).status;if(c){if(!(0,E.getInitDeferred)(i)){(0,E.createInitDeferred)(i,s.direction??"tail").promise.catch(()=>{})}(0,S.refreshAgentInitializationTimeout)({key:i,agentId:n,setAgentInitializing:e}),e(n,!0)}try{const o=await(0,A.getHostRuntimeStore)().fetchAgentTimeline(t,n,s);return c&&(0,E.getInitDeferred)(i)&&(0,S.refreshAgentInitializationTimeout)({key:i,agentId:n,setAgentInitializing:e}),o}catch(t){throw c&&(e(n,!1),(0,E.rejectInitDeferred)(i,t instanceof Error?t:new Error(String(t)))),t}},fetchLatestTail:e=>(0,A.getHostRuntimeStore)().fetchAgentTimeline(t,e,(0,h.planTimelineTailFetch)()),reportError:e=>{console.warn("[Session] viewed timeline synchronization failed",{serverId:t,error:e})},schedule:(e,t)=>{const n=setTimeout(e,t);return()=>clearTimeout(n)}});ae.current=o,Z(t,o),o.setActive((0,q.getIsAppVisible)(re.current));const i=(0,c.observeOpenWorkspaceAgentIds)(t,e=>o.replaceOpenAgentIds(e));return()=>{i(),ae.current===o&&(ae.current=null),Z(t,null),o.dispose()}},[s,t,Q,Z,z]),(0,n.useEffect)(()=>{ae.current?.setConnected(U)},[U]),(0,n.useEffect)(()=>{const e=s.observeEvents(["agent_attention_required","terminal_attention_required","agent_permission_request","agent_permission_resolved","agent.provider_subagents.update","checkout_status_update","workspace_setup_progress","status.server_info"],{notifications:!0}),n=(t,n)=>e.subscribe({snapshot:()=>{},update:e=>{e.type===t&&n(e)}}),o=n("agent_attention_required",e=>{if("agent_attention_required"!==e.type)return;const t=e.payload;t.shouldNotify&&de(t)}),i=n("agent.provider_subagents.update",e=>{"agent.provider_subagents.update"===e.type&&F.useProviderSubagentStore.getState().applyUpdate(t,e.payload)}),c=n("checkout_status_update",e=>{"checkout_status_update"===e.type&&(0,V.applyCheckoutStatusUpdateFromEvent)({queryClient:N,serverId:t,message:e})}),u=n("workspace_setup_progress",e=>{"workspace_setup_progress"===e.type&&ue(e.payload)}),l=n("status",e=>{if("status"!==e.type)return;const n=(0,b.parseServerInfoStatusPayload)(e.payload);n&&Y(t,Object.assign({serverId:n.serverId,hostname:n.hostname,version:n.version},void 0!==n.desktopManaged?{desktopManaged:n.desktopManaged}:{},n.capabilities?{capabilities:n.capabilities}:{},n.features?{features:n.features}:{}))}),p=n("agent_permission_request",e=>{if("agent_permission_request"!==e.type)return;const{agentId:n,request:s}=e.payload;X(t,e=>{const t=new Map(e),o=(0,P.derivePendingPermissionKey)(n,s);return t.set(o,{key:o,agentId:n,request:s}),t})}),f=n("agent_permission_resolved",e=>{if("agent_permission_resolved"!==e.type)return;const{requestId:n,agentId:s}=e.payload;X(t,e=>{const t=new Map(e),o=`${s}:${n}`;if(!t.delete(o))for(const[e,o]of t.entries())if(o.agentId===s&&o.request.id===n){t.delete(e);break}return t})}),y=s.on("audio_output",async e=>{if("audio_output"!==e.type)return;if(!x)return;const n=e.payload;if(n.isVoiceMode&&z)return void z.handleAudioOutput(t,n);const o=n.groupId??n.id,i=n.chunkIndex??0,c=n.isLastChunk??!0;oe.current.has(o)||oe.current.set(o,[]);const u=oe.current.get(o);if(u.push({chunkIndex:i,audio:n.audio,format:n.format,id:n.id}),ie.current.add(o),$(t,!0),!c)return;u.sort((e,t)=>e.chunkIndex-t.chunkIndex);const l=u.map(e=>e.id),p=!n.isVoiceMode||(z?.shouldPlayVoiceAudio(t)??!1),f=H(u);function y(e){console.warn("[Session] Failed to confirm audio playback:",e)}const S=async()=>{await Promise.all(l.map(e=>s.audioPlayed(e).catch(y)))};let v=!1;try{p&&(n.isVoiceMode&&(v=!0,z?.onAssistantAudioStarted(t)),await x.play(f)),await S()}catch(e){console.error("[Session] Audio playback error:",e),await S()}finally{oe.current.delete(o),ie.current.delete(o),$(t,ie.current.size>0),v&&z?.onAssistantAudioFinished(t)}}),S=s.on("activity_log",e=>{var t,n;"activity_log"===e.type&&(t=e.payload,n=D.error,"error"===t.type&&!0===t.metadata?.voiceAbortFailed&&n(t.content))}),v=s.on("transcription_result",e=>{if("transcription_result"!==e.type)return;const n=e.payload.text.trim();z?.onTranscriptionResult(t,n)}),h=s.on("voice_input_state",e=>{"voice_input_state"===e.type&&z?.onServerSpeechStateChanged(t,e.payload.isSpeaking)}),I=n("terminal_attention_required",e=>{"terminal_attention_required"===e.type&&e.payload.shouldNotify&&(0,M.sendOsNotification)({title:e.payload.title,body:e.payload.body,data:Object.assign({serverId:e.payload.serverId??t,terminalId:e.payload.terminalId,cwd:e.payload.cwd},e.payload.workspaceId?{workspaceId:e.payload.workspaceId}:{})})});return()=>{e.release().catch(e=>console.warn("[Session] Failed to release feeds",e)),i(),o(),c(),u(),l(),p(),f(),y(),S(),v(),h(),I()}},[s,N,t,$,B,K,W,Q,G,X,de,ue,Y,D,z,x]);(0,n.useCallback)(e=>{s?s.cancelAgent(e).catch(e=>{console.error("[Session] Failed to cancel agent:",e)}):console.warn("[Session] cancelAgent skipped: daemon unavailable")},[s]),(0,n.useCallback)(e=>{s?s.deleteAgent(e).catch(e=>{console.error("[Session] Failed to delete agent:",e)}):console.warn("[Session] deleteAgent skipped: daemon unavailable")},[s]),(0,n.useCallback)(e=>{s?s.archiveAgent(e).catch(e=>{console.error("[Session] Failed to archive agent:",e)}):console.warn("[Session] archiveAgent skipped: daemon unavailable")},[s]),(0,n.useCallback)(e=>{s?s.restartServer(e).catch(e=>{console.error("[Session] Failed to restart server:",e)}):console.warn("[Session] restartServer skipped: daemon unavailable")},[s]),(0,n.useCallback)((e,t)=>{s?s.setAgentMode(e,t).then(e=>(0,O.showProviderNoticeToast)(D,e)).catch(e=>{console.error("[Session] Failed to set agent mode:",e),D.error((0,R.toErrorMessage)(e))}):console.warn("[Session] setAgentMode skipped: daemon unavailable")},[s,D]),(0,n.useCallback)((e,t)=>{s?s.setAgentModel(e,t).catch(e=>{console.error("[Session] Failed to set agent model:",e),D.error((0,R.toErrorMessage)(e))}):console.warn("[Session] setAgentModel skipped: daemon unavailable")},[s,D]),(0,n.useCallback)((e,t)=>{s?s.setAgentThinkingOption(e,t).then(e=>(0,O.showProviderNoticeToast)(D,e)).catch(e=>{console.error("[Session] Failed to set agent thinking option:",e),D.error((0,R.toErrorMessage)(e))}):console.warn("[Session] setAgentThinkingOption skipped: daemon unavailable")},[s,D]),(0,n.useCallback)((e,t,n)=>{s?s.respondToPermission(e,t,n).catch(e=>{console.error("[Session] Failed to respond to permission:",e)}):console.warn("[Session] respondToPermission skipped: daemon unavailable")},[s]);return e}},4508,[453,36,52,397,3557,799,853,4509,4512,3633,4514,3628,3626,4515,3474,4516,3466,4442,3420,3532,4517,4513,3611,3595,893,3571,4386,3839,4532,279]);
|
|
16163
|
+
__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SessionProvider=function(e){const n=(0,t.c)(2);let s;n[0]!==e?(s=(0,z.jsx)(x,Object.assign({},e)),n[0]=e,n[1]=s):s=n[1];return s};var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),i=(e=o)&&e.__esModule?e:{default:e},c=r(d[4]),u=r(d[5]),l=r(d[6]),p=r(d[7]),f=r(d[8]),y=r(d[9]),S=r(d[10]),v=r(d[11]),h=r(d[12]),I=r(d[13]),b=r(d[14]),_=r(d[15]),A=r(d[16]),k=r(d[17]),w=r(d[18]),T=r(d[19]),M=r(d[20]),q=r(d[21]),E=r(d[22]),P=r(d[23]),C=r(d[24]),R=r(d[25]),O=r(d[26]),V=r(d[27]),F=r(d[28]),z=r(d[29]);function H(e){const t=e.map(e=>{return t=e.audio,s.Buffer.from(t,"base64");var t}),n=t.reduce((e,t)=>e+t.length,0),o=new Uint8Array(n);let i=0;for(const e of t)o.set(e,i),i+=e.length;const c=e[0]?.format??"pcm";let u;u="pcm"===c?"audio/pcm;rate=24000;bits=16":"mp3"===c?"audio/mpeg":`audio/${c}`;const l=o.slice();return{size:l.byteLength,type:u,arrayBuffer:async()=>l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}}const L=e=>{for(let t=e.length-1;t>=0;t-=1){const n=e[t];if("assistant_message"===n.kind)return n.text}return null},j=(e,t)=>{if(!e)return null;let n=null;for(const s of e.pendingPermissions.values())s.agentId===t&&(n=s.request);if(n)return n;const s=e.agents.get(t)?.pendingPermissions;return s&&s.length>0?s[s.length-1]:null};function x(e){const n=(0,t.c)(4),{children:s,serverId:o,client:i}=e;let c;return n[0]!==s||n[1]!==i||n[2]!==o?(c=(0,z.jsx)(N,{serverId:o,client:i,children:s}),n[0]=s,n[1]=i,n[2]=o,n[3]=c):c=n[3],c}function N({children:e,serverId:t,client:s}){const{t:o}=(0,l.useTranslation)(),z=(0,k.useVoiceRuntimeOptional)(),x=(0,k.useVoiceAudioEngineOptional)(),N=(0,u.useQueryClient)(),U=(0,A.useHostRuntimeIsConnected)(t),D=(0,C.useToast)(),$=(0,w.useSessionStore)(e=>e.setIsPlayingAudio),B=(0,w.useSessionStore)(e=>e.setAgentStreamTail),K=(0,w.useSessionStore)(e=>e.setAgentStreamHead),W=(0,w.useSessionStore)(e=>e.clearAgentStreamHead),Q=(0,w.useSessionStore)(e=>e.setInitializingAgents),G=(0,w.useSessionStore)(e=>e.setAgents),J=(0,w.useSessionStore)(e=>e.flushAgentLastActivity),X=(0,w.useSessionStore)(e=>e.setPendingPermissions),Y=(0,w.useSessionStore)(e=>e.updateSessionServerInfo),Z=(0,w.useSessionStore)(e=>e.setViewedTimelineSync),ee=(0,T.useWorkspaceSetupStore)(e=>e.upsertProgress),te=(0,w.useSessionStore)(e=>e.sessions[t]?.focusedAgentId??null),ne=(0,w.useSessionStore)(e=>e.sessions[t]?.focusedTerminalId??null),se=((0,n.useRef)(null),(0,n.useRef)(new Map)),re=(0,n.useRef)(i.default.currentState),ae=(0,n.useRef)(null),oe=(0,n.useRef)(new Map),ie=(0,n.useRef)(new Set),ce=(0,f.useAppVisible)();(0,n.useEffect)(()=>{const e=i.default.addEventListener("change",e=>{re.current=e});return()=>{e.remove()}},[]),(0,n.useEffect)(()=>{ae.current?.setActive(ce)},[ce]),(0,p.useClientActivity)({client:s,focusedAgentId:te,focusedTerminalId:ne}),(0,n.useEffect)(()=>(0,y.startPushNotifications)({client:s,serverId:t}),[s,t]);const de=(0,n.useCallback)(e=>{const n=re.current,s=w.useSessionStore.getState().sessions[t],o=s?.focusedAgentId??null;if("error"===e.reason)return;if(!(!(0,q.getIsAppActivelyVisible)(n)||o!==e.agentId))return;const i=new Date(e.timestamp).getTime(),c=se.current.get(e.agentId);if(c&&c>=i)return;se.current.set(e.agentId,i);const u=s?.agentStreamHead.get(e.agentId)??[],l=s?.agentStreamTail.get(e.agentId)??[],p=L(u)??L(l),f=j(s,e.agentId),y=s?.agents?.get(e.agentId)?.workspaceId,S=(v={notification:e.notification,reason:e.reason,serverId:t,workspaceId:y,agentId:e.agentId,assistantMessage:p,permissionRequest:f}).notification?v.notification.data.workspaceId?v.notification:null:v.workspaceId?(0,_.buildAgentAttentionNotificationPayload)({reason:v.reason,serverId:v.serverId,workspaceId:v.workspaceId,agentId:v.agentId,assistantMessage:"finished"===v.reason?v.assistantMessage:null,permissionRequest:"permission"===v.reason?v.permissionRequest:null}):null;var v;S&&(0,M.sendOsNotification)({title:S.title,body:S.body,data:S.data})},[t]);(0,n.useEffect)(()=>{const e=s.getLastServerInfoMessage();e&&Y(t,Object.assign({serverId:e.serverId,hostname:e.hostname,version:e.version},void 0!==e.desktopManaged?{desktopManaged:e.desktopManaged}:{},e.capabilities?{capabilities:e.capabilities}:{},e.features?{features:e.features}:{}))},[s,t,Y]),(0,n.useEffect)(()=>{const e=z?.registerSession({serverId:t,setVoiceMode:async(e,t)=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.setVoiceMode(e,t)},sendVoiceAudioChunk:async(e,t)=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.sendVoiceAudioChunk(e,t)},audioPlayed:async e=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.audioPlayed(e)},abortRequest:async()=>{if(!s)throw new Error(o("common.errors.daemonUnavailable"));await s.abortRequest()},setAssistantAudioPlaying:e=>{$(t,e)}});return()=>e?.()},[s,t,$,o,z]),(0,n.useEffect)(()=>{z?.updateSessionConnection(t,U)},[U,t,z]),(0,n.useEffect)(()=>{U||(J(),Q(t,new Map))},[J,t,U,Q]);const ue=(0,n.useCallback)(e=>{ee({serverId:t,payload:e})},[t,ee]);(0,n.useEffect)(()=>{const e=(0,S.createSetAgentInitializing)(t,Q),n=e=>{if("agent_stream"!==e.type)return;const{agentId:n,event:s,timestamp:i,seq:c,epoch:u}=e.payload,l=new Date(i),p=s;"turn_started"!==s.type&&"turn_completed"!==s.type&&"turn_failed"!==s.type&&"turn_canceled"!==s.type||z?.onTurnEvent(t,n,s.type);const f=(0,v.deriveAgentStreamTurnLiveness)([{event:p,seq:c,epoch:u,timestamp:l}]);f.length>0&&(0,A.getHostRuntimeStore)().applyAgentTurnLiveness(t,n,f),o.enqueueStreamEvent(n,{event:p,seq:c,epoch:u,timestamp:l})},o=(0,A.getHostRuntimeStore)().createViewedTimelineOwner(t,{observe:e=>{const o=s.observeTimeline(e);return o.subscribe({snapshot:()=>{},update:e=>{var s;"agent_stream"===e.type?n(e):"agent.timeline.replacement"===e.type&&("agent.timeline.replacement"===(s=e).type&&(0,I.requestTimelineReplacement)({fetchAgentTimeline:(e,n)=>(0,A.getHostRuntimeStore)().fetchAgentTimeline(t,e,n)},s.payload.agentId).catch(e=>{console.warn("[Session] timeline replacement refresh failed",{serverId:t,error:e})}))}}),o},readCursor:e=>{const n=(0,w.selectAgentTimelineState)(w.useSessionStore.getState().sessions[t],e);return"synced"===n.status&&n.range?{epoch:n.range.epoch,endSeq:n.range.endSeq}:void 0},fetchPage:async(n,s)=>{const o=w.useSessionStore.getState().sessions[t],i=(0,E.getInitKey)(t,n),c="synced"!==(0,w.selectAgentTimelineState)(o,n).status;if(c){if(!(0,E.getInitDeferred)(i)){(0,E.createInitDeferred)(i,s.direction??"tail").promise.catch(()=>{})}(0,S.refreshAgentInitializationTimeout)({key:i,agentId:n,setAgentInitializing:e}),e(n,!0)}try{const o=await(0,A.getHostRuntimeStore)().fetchAgentTimeline(t,n,s);return c&&(0,E.getInitDeferred)(i)&&(0,S.refreshAgentInitializationTimeout)({key:i,agentId:n,setAgentInitializing:e}),o}catch(t){throw c&&(e(n,!1),(0,E.rejectInitDeferred)(i,t instanceof Error?t:new Error(String(t)))),t}},fetchLatestTail:e=>(0,A.getHostRuntimeStore)().fetchAgentTimeline(t,e,(0,h.planTimelineTailFetch)()),reportError:e=>{console.warn("[Session] viewed timeline synchronization failed",{serverId:t,error:e})},schedule:(e,t)=>{const n=setTimeout(e,t);return()=>clearTimeout(n)}});ae.current=o,Z(t,o),o.setActive((0,q.getIsAppVisible)(re.current));const i=(0,c.observeOpenWorkspaceAgentIds)(t,e=>o.replaceOpenTabAgentIds(e));return()=>{i(),ae.current===o&&(ae.current=null),Z(t,null),o.dispose()}},[s,t,Q,Z,z]),(0,n.useEffect)(()=>{ae.current?.setConnected(U)},[U]),(0,n.useEffect)(()=>{const e=s.observeEvents(["agent_attention_required","terminal_attention_required","agent_permission_request","agent_permission_resolved","agent.provider_subagents.update","checkout_status_update","workspace_setup_progress","status.server_info"],{notifications:!0}),n=(t,n)=>e.subscribe({snapshot:()=>{},update:e=>{e.type===t&&n(e)}}),o=n("agent_attention_required",e=>{if("agent_attention_required"!==e.type)return;const t=e.payload;t.shouldNotify&&de(t)}),i=n("agent.provider_subagents.update",e=>{"agent.provider_subagents.update"===e.type&&F.useProviderSubagentStore.getState().applyUpdate(t,e.payload)}),c=n("checkout_status_update",e=>{"checkout_status_update"===e.type&&(0,V.applyCheckoutStatusUpdateFromEvent)({queryClient:N,serverId:t,message:e})}),u=n("workspace_setup_progress",e=>{"workspace_setup_progress"===e.type&&ue(e.payload)}),l=n("status",e=>{if("status"!==e.type)return;const n=(0,b.parseServerInfoStatusPayload)(e.payload);n&&Y(t,Object.assign({serverId:n.serverId,hostname:n.hostname,version:n.version},void 0!==n.desktopManaged?{desktopManaged:n.desktopManaged}:{},n.capabilities?{capabilities:n.capabilities}:{},n.features?{features:n.features}:{}))}),p=n("agent_permission_request",e=>{if("agent_permission_request"!==e.type)return;const{agentId:n,request:s}=e.payload;X(t,e=>{const t=new Map(e),o=(0,P.derivePendingPermissionKey)(n,s);return t.set(o,{key:o,agentId:n,request:s}),t})}),f=n("agent_permission_resolved",e=>{if("agent_permission_resolved"!==e.type)return;const{requestId:n,agentId:s}=e.payload;X(t,e=>{const t=new Map(e),o=`${s}:${n}`;if(!t.delete(o))for(const[e,o]of t.entries())if(o.agentId===s&&o.request.id===n){t.delete(e);break}return t})}),y=s.on("audio_output",async e=>{if("audio_output"!==e.type)return;if(!x)return;const n=e.payload;if(n.isVoiceMode&&z)return void z.handleAudioOutput(t,n);const o=n.groupId??n.id,i=n.chunkIndex??0,c=n.isLastChunk??!0;oe.current.has(o)||oe.current.set(o,[]);const u=oe.current.get(o);if(u.push({chunkIndex:i,audio:n.audio,format:n.format,id:n.id}),ie.current.add(o),$(t,!0),!c)return;u.sort((e,t)=>e.chunkIndex-t.chunkIndex);const l=u.map(e=>e.id),p=!n.isVoiceMode||(z?.shouldPlayVoiceAudio(t)??!1),f=H(u);function y(e){console.warn("[Session] Failed to confirm audio playback:",e)}const S=async()=>{await Promise.all(l.map(e=>s.audioPlayed(e).catch(y)))};let v=!1;try{p&&(n.isVoiceMode&&(v=!0,z?.onAssistantAudioStarted(t)),await x.play(f)),await S()}catch(e){console.error("[Session] Audio playback error:",e),await S()}finally{oe.current.delete(o),ie.current.delete(o),$(t,ie.current.size>0),v&&z?.onAssistantAudioFinished(t)}}),S=s.on("activity_log",e=>{var t,n;"activity_log"===e.type&&(t=e.payload,n=D.error,"error"===t.type&&!0===t.metadata?.voiceAbortFailed&&n(t.content))}),v=s.on("transcription_result",e=>{if("transcription_result"!==e.type)return;const n=e.payload.text.trim();z?.onTranscriptionResult(t,n)}),h=s.on("voice_input_state",e=>{"voice_input_state"===e.type&&z?.onServerSpeechStateChanged(t,e.payload.isSpeaking)}),I=n("terminal_attention_required",e=>{"terminal_attention_required"===e.type&&e.payload.shouldNotify&&(0,M.sendOsNotification)({title:e.payload.title,body:e.payload.body,data:Object.assign({serverId:e.payload.serverId??t,terminalId:e.payload.terminalId,cwd:e.payload.cwd},e.payload.workspaceId?{workspaceId:e.payload.workspaceId}:{})})});return()=>{e.release().catch(e=>console.warn("[Session] Failed to release feeds",e)),i(),o(),c(),u(),l(),p(),f(),y(),S(),v(),h(),I()}},[s,N,t,$,B,K,W,Q,G,X,de,ue,Y,D,z,x]);(0,n.useCallback)(e=>{s?s.cancelAgent(e).catch(e=>{console.error("[Session] Failed to cancel agent:",e)}):console.warn("[Session] cancelAgent skipped: daemon unavailable")},[s]),(0,n.useCallback)(e=>{s?s.deleteAgent(e).catch(e=>{console.error("[Session] Failed to delete agent:",e)}):console.warn("[Session] deleteAgent skipped: daemon unavailable")},[s]),(0,n.useCallback)(e=>{s?s.archiveAgent(e).catch(e=>{console.error("[Session] Failed to archive agent:",e)}):console.warn("[Session] archiveAgent skipped: daemon unavailable")},[s]),(0,n.useCallback)(e=>{s?s.restartServer(e).catch(e=>{console.error("[Session] Failed to restart server:",e)}):console.warn("[Session] restartServer skipped: daemon unavailable")},[s]),(0,n.useCallback)((e,t)=>{s?s.setAgentMode(e,t).then(e=>(0,O.showProviderNoticeToast)(D,e)).catch(e=>{console.error("[Session] Failed to set agent mode:",e),D.error((0,R.toErrorMessage)(e))}):console.warn("[Session] setAgentMode skipped: daemon unavailable")},[s,D]),(0,n.useCallback)((e,t)=>{s?s.setAgentModel(e,t).catch(e=>{console.error("[Session] Failed to set agent model:",e),D.error((0,R.toErrorMessage)(e))}):console.warn("[Session] setAgentModel skipped: daemon unavailable")},[s,D]),(0,n.useCallback)((e,t)=>{s?s.setAgentThinkingOption(e,t).then(e=>(0,O.showProviderNoticeToast)(D,e)).catch(e=>{console.error("[Session] Failed to set agent thinking option:",e),D.error((0,R.toErrorMessage)(e))}):console.warn("[Session] setAgentThinkingOption skipped: daemon unavailable")},[s,D]),(0,n.useCallback)((e,t,n)=>{s?s.respondToPermission(e,t,n).catch(e=>{console.error("[Session] Failed to respond to permission:",e)}):console.warn("[Session] respondToPermission skipped: daemon unavailable")},[s]);return e}},4508,[453,36,52,397,3557,799,853,4509,4512,3633,4514,3628,3626,4515,3474,4516,3466,4442,3420,3532,4517,4513,3611,3595,893,3571,4386,3839,4532,279]);
|
|
16164
16164
|
__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useClientActivity=function({client:e,focusedAgentId:n,focusedTerminalId:v,onAppResumed:f}){const w=(0,t.useRef)(f);w.current=f;const E=(0,t.useRef)(null);E.current||(E.current=(0,l.createClientActivityTracker)({client:e,deviceType:o.isWeb?"web":"mobile",initialFocusedAgentId:n,initialFocusedTerminalId:v,initialAppVisible:"active"===s.default.currentState,now:()=>Date.now(),onAppResumed:e=>w.current?.(e)}));const y=E.current;(0,t.useEffect)(()=>{const e=s.default.addEventListener("change",e=>{y.notifyAppVisibility("active"===e),y.sendHeartbeat()});return()=>e.remove()},[y]),(0,t.useEffect)(()=>{if(o.isNative)return;if("undefined"==typeof document)return;const e=()=>{y.recordUserActivity(),y.maybeSendImmediateHeartbeat()},t=()=>{const e="visible"===document.visibilityState,{changed:t}=y.notifyAppVisibility(e);t&&e&&y.maybeSendImmediateHeartbeat()};return document.addEventListener("visibilitychange",t),window.addEventListener("focus",e),window.addEventListener("pointerdown",e,{passive:!0}),window.addEventListener("keydown",e),window.addEventListener("wheel",e,{passive:!0}),window.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("focus",e),window.removeEventListener("pointerdown",e),window.removeEventListener("keydown",e),window.removeEventListener("wheel",e),window.removeEventListener("touchstart",e)}},[y]),(0,t.useEffect)(()=>{if(!(0,o.getIsElectron)())return;let e=!1;const t=async()=>{const t=await(0,c.readDesktopSystemIdleTimeMs)(u.invokeDesktopCommand);e||y.notifySystemIdleMs(t)},n=setInterval(()=>{t()},l.DESKTOP_IDLE_POLL_INTERVAL_MS);return()=>{e=!0,clearInterval(n)}},[y]),(0,t.useEffect)(()=>{y.setFocusedAgentId(n)},[n,y]),(0,t.useEffect)(()=>{y.setFocusedTerminalId(v)},[v,y]),(0,t.useEffect)(()=>{let t=null;const n=()=>{t&&(clearInterval(t),t=null)},s=e.subscribeConnectionStatus(e=>{"connected"===e.status?(t&&clearInterval(t),y.sendHeartbeat(),t=setInterval(()=>y.sendHeartbeat(),l.HEARTBEAT_INTERVAL_MS)):n()});return()=>{s(),n()}},[e,y])};var e,t=r(d[0]),n=r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),c=r(d[3]),u=r(d[4]),l=r(d[5])},4509,[36,397,880,4510,891,4511]);
|
|
16165
16165
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readDesktopSystemIdleTimeMs=async function(s){try{const l=await s(t);return"number"==typeof(n=l)&&Number.isFinite(n)&&n>=0?l:(console.warn("[DesktopIdle] Invalid system idle time",l),null)}catch(t){return console.warn("[DesktopIdle] Failed to read system idle time",t),null}var n};const t="desktop_get_system_idle_time"},4510,[]);
|
|
16166
16166
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HEARTBEAT_INTERVAL_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ACTIVITY_HEARTBEAT_THROTTLE_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESKTOP_IDLE_POLL_INTERVAL_MS",{enumerable:!0,get:function(){return c}}),e.createClientActivityTracker=function(t){const{client:c,deviceType:u,now:o,onAppResumed:s}=t;let l=o(),f=t.initialAppVisible,A=o(),T=f?null:o(),p=t.initialFocusedAgentId,b=t.initialFocusedTerminalId,y=0;function I(){c.isConnected&&c.sendHeartbeat({deviceType:u,focusedAgentId:p,focusedTerminalId:b,lastActivityAt:new Date(l).toISOString(),appVisible:f,appVisibilityChangedAt:new Date(A).toISOString()})}function _(){l=o()}return{recordUserActivity:_,maybeSendImmediateHeartbeat:function(){if(!c.isConnected)return;const t=o();t-y<n||(y=t,I())},setFocusedAgentId(t){p!==t&&(p=t,_(),I())},setFocusedTerminalId(t){b!==t&&(b=t,_(),I())},notifyAppVisibility(t){if(f===t)return{changed:!1};if(f=t,A=o(),!t)return T=o(),{changed:!0};const n=T;return T=null,null!==n&&s?.(Math.max(0,o()-n)),_(),{changed:!0}},notifySystemIdleMs(t){if(null===t)return;const n=o()-t;n>l&&(l=n)},sendHeartbeat:I}};const t=15e3,n=5e3,c=5e3},4511,[]);
|
|
Binary file
|
|
Binary file
|
|
@@ -85,6 +85,6 @@
|
|
|
85
85
|
<body>
|
|
86
86
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
87
87
|
<div id="root"></div>
|
|
88
|
-
<script src="/_expo/static/js/web/index-
|
|
88
|
+
<script src="/_expo/static/js/web/index-81fd85915b2feba2f0f2522cbeaaf74b.js" defer></script>
|
|
89
89
|
</body>
|
|
90
90
|
</html>
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpaseo/server",
|
|
3
|
-
"version": "0.9.0-beta.
|
|
3
|
+
"version": "0.9.0-beta.2",
|
|
4
4
|
"description": "Paseo backend server",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/server",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"@agentclientprotocol/sdk": "^0.17.1",
|
|
107
107
|
"@anthropic-ai/claude-agent-sdk": "0.3.246",
|
|
108
108
|
"@anthropic-ai/sdk": "^0.104.2",
|
|
109
|
-
"@getpaseo/client": "0.9.0-beta.
|
|
110
|
-
"@getpaseo/highlight": "0.9.0-beta.
|
|
111
|
-
"@getpaseo/plugin": "0.9.0-beta.
|
|
112
|
-
"@getpaseo/protocol": "0.9.0-beta.
|
|
113
|
-
"@getpaseo/relay": "0.9.0-beta.
|
|
109
|
+
"@getpaseo/client": "0.9.0-beta.2",
|
|
110
|
+
"@getpaseo/highlight": "0.9.0-beta.2",
|
|
111
|
+
"@getpaseo/plugin": "0.9.0-beta.2",
|
|
112
|
+
"@getpaseo/protocol": "0.9.0-beta.2",
|
|
113
|
+
"@getpaseo/relay": "0.9.0-beta.2",
|
|
114
114
|
"@isaacs/ttlcache": "^2.1.4",
|
|
115
115
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
116
116
|
"@opencode-ai/sdk": "1.14.46",
|
|
Binary file
|