@prbe.ai/electron-sdk 0.1.8 → 0.1.10

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, e as InteractionPayload, f as InteractionResponse, g as PollResponse, T as TicketInfoOut } from './types-CwYRJCG0.mjs';
2
- export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolvedInteraction, J as TicketInfoRequest, K as TicketInfoResponse, L as TicketStatusOut, N as ToolName, O as ToolParamType, W as WSMessage, Q as WSMessageType, S as redactPII, U as serializePRBEState } from './types-CwYRJCG0.mjs';
1
+ import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, e as InteractionPayload, f as InteractionResponse, g as PollResponse, T as TicketInfoOut } from './types-CeIldtlI.mjs';
2
+ export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolveSessionsRequest, J as ResolveSessionsResponse, K as ResolvedInteraction, L as ResolvedTicketOut, N as TicketInfoRequest, O as TicketInfoResponse, Q as TicketStatusOut, S as ToolName, U as ToolParamType, W as WSMessage, V as WSMessageType, X as redactPII, Y as serializePRBEState } from './types-CeIldtlI.mjs';
3
3
  import 'events';
4
4
 
5
5
  /**
@@ -150,12 +150,12 @@ declare class PRBEAgent implements PRBEInteractionRequester {
150
150
  /** Files flagged during the current tool call — uploaded immediately after the tool returns. */
151
151
  private pendingFlaggedFiles;
152
152
  private get agentID();
153
- private get trackedTicketIDs();
154
- private set trackedTicketIDs(value);
153
+ private get trackedSessionIDs();
154
+ private set trackedSessionIDs(value);
155
155
  private get respondedCRIDs();
156
156
  private set respondedCRIDs(value);
157
157
  private syncPolling;
158
- private addTrackedTicket;
158
+ private addTrackedSession;
159
159
  constructor(config: PRBEAgentConfig);
160
160
  private hookElectronLog;
161
161
  private hookRendererLogs;
@@ -186,10 +186,12 @@ declare class PRBEAgent implements PRBEInteractionRequester {
186
186
  cancel(): void;
187
187
  /**
188
188
  * Poll the backend for context requests on tracked tickets.
189
+ * Resolves session IDs → ticket IDs first, then polls with ticket IDs.
189
190
  */
190
191
  poll(): Promise<PollResponse | null>;
191
192
  /**
192
- * Fetch ticket display info for all tracked tickets.
193
+ * Fetch ticket display info for all tracked sessions.
194
+ * Resolves session IDs → ticket IDs first, then fetches ticket info.
193
195
  */
194
196
  fetchTicketInfo(): Promise<TicketInfoOut[]>;
195
197
  stopPolling(): void;
@@ -214,6 +216,7 @@ declare class PRBEAgent implements PRBEInteractionRequester {
214
216
  private extractUploadPrefix;
215
217
  private static backgroundUpload;
216
218
  private startPolling;
219
+ private resolveSessions;
217
220
  /**
218
221
  * Abort all in-flight fetch requests to prevent orphaned DNS lookups
219
222
  * that can crash the c-ares resolver during process shutdown.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, e as InteractionPayload, f as InteractionResponse, g as PollResponse, T as TicketInfoOut } from './types-CwYRJCG0.js';
2
- export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolvedInteraction, J as TicketInfoRequest, K as TicketInfoResponse, L as TicketStatusOut, N as ToolName, O as ToolParamType, W as WSMessage, Q as WSMessageType, S as redactPII, U as serializePRBEState } from './types-CwYRJCG0.js';
1
+ import { P as PRBEToolDeclaration, a as PRBEToolParameter, b as PRBEInteractionRequester, F as FlaggedFileIn, c as PRBEAgentState, d as PRBEAgentConfig, I as InvestigationSource, e as InteractionPayload, f as InteractionResponse, g as PollResponse, T as TicketInfoOut } from './types-CeIldtlI.js';
2
+ export { A as API_URL, h as AskQuestionPayload, i as AskQuestionResponse, C as ContextRequestOut, D as DEFAULT_PRBE_STATE, j as InteractionType, k as InvestigationResult, M as MIDDLEWARE_URL, l as PRBEAgentConfigKey, m as PRBEAgentError, n as PRBEAgentErrorType, o as PRBEAgentStatus, p as PRBEAgentStatusType, q as PRBECRInvestigation, r as PRBECompletedInvestigation, s as PRBEInteractionHandler, t as PRBESerializedCR, u as PRBESerializedCompletedInvestigation, v as PRBESerializedState, w as PRBESerializedTicket, x as PRBEStateEvent, y as PRBEStatusEvent, z as PollRequest, R as RequestPathAccessPayload, B as RequestPathAccessResponse, E as RequestPermissionPayload, G as RequestPermissionResponse, H as ResolveSessionsRequest, J as ResolveSessionsResponse, K as ResolvedInteraction, L as ResolvedTicketOut, N as TicketInfoRequest, O as TicketInfoResponse, Q as TicketStatusOut, S as ToolName, U as ToolParamType, W as WSMessage, V as WSMessageType, X as redactPII, Y as serializePRBEState } from './types-CeIldtlI.js';
3
3
  import 'events';
4
4
 
5
5
  /**
@@ -150,12 +150,12 @@ declare class PRBEAgent implements PRBEInteractionRequester {
150
150
  /** Files flagged during the current tool call — uploaded immediately after the tool returns. */
151
151
  private pendingFlaggedFiles;
152
152
  private get agentID();
153
- private get trackedTicketIDs();
154
- private set trackedTicketIDs(value);
153
+ private get trackedSessionIDs();
154
+ private set trackedSessionIDs(value);
155
155
  private get respondedCRIDs();
156
156
  private set respondedCRIDs(value);
157
157
  private syncPolling;
158
- private addTrackedTicket;
158
+ private addTrackedSession;
159
159
  constructor(config: PRBEAgentConfig);
160
160
  private hookElectronLog;
161
161
  private hookRendererLogs;
@@ -186,10 +186,12 @@ declare class PRBEAgent implements PRBEInteractionRequester {
186
186
  cancel(): void;
187
187
  /**
188
188
  * Poll the backend for context requests on tracked tickets.
189
+ * Resolves session IDs → ticket IDs first, then polls with ticket IDs.
189
190
  */
190
191
  poll(): Promise<PollResponse | null>;
191
192
  /**
192
- * Fetch ticket display info for all tracked tickets.
193
+ * Fetch ticket display info for all tracked sessions.
194
+ * Resolves session IDs → ticket IDs first, then fetches ticket info.
193
195
  */
194
196
  fetchTicketInfo(): Promise<TicketInfoOut[]>;
195
197
  stopPolling(): void;
@@ -214,6 +216,7 @@ declare class PRBEAgent implements PRBEInteractionRequester {
214
216
  private extractUploadPrefix;
215
217
  private static backgroundUpload;
216
218
  private startPolling;
219
+ private resolveSessions;
217
220
  /**
218
221
  * Abort all in-flight fetch requests to prevent orphaned DNS lookups
219
222
  * that can crash the c-ares resolver during process shutdown.
package/dist/index.js CHANGED
@@ -192,7 +192,7 @@ var PRBEAgentState = class extends import_events.EventEmitter {
192
192
  activeCRs = /* @__PURE__ */ new Map();
193
193
  completedCRs = [];
194
194
  // Tracked tickets
195
- trackedTicketIDs = [];
195
+ trackedSessionIDs = [];
196
196
  ticketInfo = [];
197
197
  // Computed
198
198
  get hasActiveWork() {
@@ -420,8 +420,8 @@ var PRBEAgentState = class extends import_events.EventEmitter {
420
420
  this.emit("status" /* STATUS */);
421
421
  }
422
422
  // ---------- Tickets ----------
423
- updateTrackedTicketIDs(ids) {
424
- this.trackedTicketIDs = ids;
423
+ updateTrackedSessionIDs(ids) {
424
+ this.trackedSessionIDs = ids;
425
425
  this.emit("tickets-changed" /* TICKETS_CHANGED */, ids);
426
426
  this.emit("status" /* STATUS */);
427
427
  }
@@ -699,7 +699,8 @@ var SearchContentTool = class {
699
699
  { name: "pattern", type: "STRING" /* STRING */, description: "Regex pattern", required: true },
700
700
  { name: "path", type: "STRING" /* STRING */, description: "File or directory to search", required: true },
701
701
  { name: "context_lines", type: "INTEGER" /* INTEGER */, description: "Context lines (default 2)", required: false },
702
- { name: "max_results", type: "INTEGER" /* INTEGER */, description: "Max results (default 50)", required: false }
702
+ { name: "max_results", type: "INTEGER" /* INTEGER */, description: "Max results (default 50)", required: false },
703
+ { name: "case_sensitive", type: "BOOLEAN" /* BOOLEAN */, description: "Case-sensitive search (default false)", required: false }
703
704
  ]
704
705
  };
705
706
  }
@@ -712,9 +713,10 @@ var SearchContentTool = class {
712
713
  if (!resolved) return `Error: ${resolveErr}`;
713
714
  const contextLines = typeof args["context_lines"] === "number" ? args["context_lines"] : 2;
714
715
  const maxResults = typeof args["max_results"] === "number" ? args["max_results"] : 50;
716
+ const caseSensitive = args["case_sensitive"] === true;
715
717
  let regex;
716
718
  try {
717
- regex = new RegExp(pattern);
719
+ regex = new RegExp(pattern, caseSensitive ? "" : "i");
718
720
  } catch {
719
721
  return `Error: invalid regex pattern '${pattern}'`;
720
722
  }
@@ -802,7 +804,8 @@ var FindFilesTool = class {
802
804
  parameters: [
803
805
  { name: "pattern", type: "STRING" /* STRING */, description: "Glob pattern", required: true },
804
806
  { name: "path", type: "STRING" /* STRING */, description: "Directory to search", required: true },
805
- { name: "max_results", type: "INTEGER" /* INTEGER */, description: "Max results (default 50)", required: false }
807
+ { name: "max_results", type: "INTEGER" /* INTEGER */, description: "Max results (default 50)", required: false },
808
+ { name: "case_sensitive", type: "BOOLEAN" /* BOOLEAN */, description: "Case-sensitive matching (default false)", required: false }
806
809
  ]
807
810
  };
808
811
  }
@@ -814,8 +817,9 @@ var FindFilesTool = class {
814
817
  const [resolved, resolveErr] = await resolvePath(pathStr, this.autoApprovedDirs, this.requester, this.grantedPaths);
815
818
  if (!resolved) return `Error: ${resolveErr}`;
816
819
  const maxResults = typeof args["max_results"] === "number" ? args["max_results"] : 50;
820
+ const caseSensitive = args["case_sensitive"] === true;
817
821
  const matches = [];
818
- this.walkAndMatch(resolved, pattern, matches);
822
+ this.walkAndMatch(resolved, pattern, matches, caseSensitive);
819
823
  matches.sort((a, b) => b.modified.getTime() - a.modified.getTime());
820
824
  const limited = matches.slice(0, maxResults);
821
825
  if (limited.length === 0) {
@@ -832,7 +836,7 @@ var FindFilesTool = class {
832
836
  }
833
837
  return result;
834
838
  }
835
- walkAndMatch(dirPath, pattern, matches) {
839
+ walkAndMatch(dirPath, pattern, matches, caseSensitive) {
836
840
  let entries;
837
841
  try {
838
842
  entries = fs.readdirSync(dirPath, { withFileTypes: true });
@@ -843,9 +847,9 @@ var FindFilesTool = class {
843
847
  if (entry.name.startsWith(".")) continue;
844
848
  const fullPath = path2.join(dirPath, entry.name);
845
849
  if (entry.isDirectory()) {
846
- this.walkAndMatch(fullPath, pattern, matches);
850
+ this.walkAndMatch(fullPath, pattern, matches, caseSensitive);
847
851
  } else if (entry.isFile()) {
848
- if (this.globMatch(entry.name, pattern)) {
852
+ if (this.globMatch(entry.name, pattern, caseSensitive)) {
849
853
  try {
850
854
  const stat = fs.statSync(fullPath);
851
855
  matches.push({
@@ -863,7 +867,7 @@ var FindFilesTool = class {
863
867
  * Simple glob matching: supports *, ?, and character classes [...].
864
868
  * Converts glob to regex and tests against the filename.
865
869
  */
866
- globMatch(filename, pattern) {
870
+ globMatch(filename, pattern, caseSensitive) {
867
871
  let regexStr = "^";
868
872
  for (let i = 0; i < pattern.length; i++) {
869
873
  const c = pattern[i];
@@ -901,7 +905,7 @@ var FindFilesTool = class {
901
905
  }
902
906
  regexStr += "$";
903
907
  try {
904
- return new RegExp(regexStr).test(filename);
908
+ return new RegExp(regexStr, caseSensitive ? "" : "i").test(filename);
905
909
  } catch {
906
910
  return false;
907
911
  }
@@ -1810,13 +1814,13 @@ var PRBEAgent = class _PRBEAgent {
1810
1814
  savePersistedData(this.persistedData);
1811
1815
  return newID;
1812
1816
  }
1813
- get trackedTicketIDs() {
1814
- return this.persistedData.ticketIds ?? [];
1817
+ get trackedSessionIDs() {
1818
+ return this.persistedData.sessionIds ?? [];
1815
1819
  }
1816
- set trackedTicketIDs(ids) {
1817
- this.persistedData.ticketIds = ids;
1820
+ set trackedSessionIDs(ids) {
1821
+ this.persistedData.sessionIds = ids;
1818
1822
  savePersistedData(this.persistedData);
1819
- this.state.updateTrackedTicketIDs(ids);
1823
+ this.state.updateTrackedSessionIDs(ids);
1820
1824
  this.syncPolling(ids.length > 0);
1821
1825
  }
1822
1826
  get respondedCRIDs() {
@@ -1826,19 +1830,19 @@ var PRBEAgent = class _PRBEAgent {
1826
1830
  this.persistedData.respondedCRIds = Array.from(ids);
1827
1831
  savePersistedData(this.persistedData);
1828
1832
  }
1829
- syncPolling(hasTickets) {
1830
- if (this.config.backgroundPolling && hasTickets) {
1833
+ syncPolling(hasSessions) {
1834
+ if (this.config.backgroundPolling && hasSessions) {
1831
1835
  if (this.pollingTimer === null) {
1832
1836
  this.startPolling();
1833
1837
  }
1834
- } else if (!hasTickets) {
1838
+ } else if (!hasSessions) {
1835
1839
  this.stopPolling();
1836
1840
  }
1837
1841
  }
1838
- addTrackedTicket(id) {
1839
- const ids = this.trackedTicketIDs;
1842
+ addTrackedSession(id) {
1843
+ const ids = this.trackedSessionIDs;
1840
1844
  if (!ids.includes(id)) {
1841
- this.trackedTicketIDs = [...ids, id];
1845
+ this.trackedSessionIDs = [...ids, id];
1842
1846
  }
1843
1847
  }
1844
1848
  // ---------- Constructor ----------
@@ -1896,9 +1900,9 @@ var PRBEAgent = class _PRBEAgent {
1896
1900
  if (config.ipcMain) {
1897
1901
  this.hookRendererLogs(config.ipcMain, config.rendererLogChannel ?? "prbe-renderer-log");
1898
1902
  }
1899
- const existingTickets = this.trackedTicketIDs;
1900
- if (existingTickets.length > 0) {
1901
- this.trackedTicketIDs = existingTickets;
1903
+ const existingSessions = this.trackedSessionIDs;
1904
+ if (existingSessions.length > 0) {
1905
+ this.trackedSessionIDs = existingSessions;
1902
1906
  }
1903
1907
  }
1904
1908
  // ---------- Log integration ----------
@@ -2029,8 +2033,8 @@ var PRBEAgent = class _PRBEAgent {
2029
2033
  );
2030
2034
  this.currentInvestigationSource = "user" /* USER */;
2031
2035
  this.currentCRId = null;
2032
- if (result?.ticketId) {
2033
- this.addTrackedTicket(result.ticketId);
2036
+ if (result?.sessionId) {
2037
+ this.addTrackedSession(result.sessionId);
2034
2038
  } else if (!result) {
2035
2039
  if (this.state.isInvestigating) {
2036
2040
  const message = this.userCancelled ? "Investigation cancelled" : "Investigation ended unexpectedly";
@@ -2062,33 +2066,37 @@ var PRBEAgent = class _PRBEAgent {
2062
2066
  }
2063
2067
  /**
2064
2068
  * Poll the backend for context requests on tracked tickets.
2069
+ * Resolves session IDs → ticket IDs first, then polls with ticket IDs.
2065
2070
  */
2066
2071
  async poll() {
2067
- const ticketIDs = this.trackedTicketIDs;
2068
- if (ticketIDs.length === 0) return null;
2069
- const request = {
2070
- agent_id: this.agentID,
2071
- ticket_ids: ticketIDs
2072
- };
2072
+ const sessionIDs = this.trackedSessionIDs;
2073
+ if (sessionIDs.length === 0) return null;
2073
2074
  try {
2075
+ const resolved = await this.resolveSessions(sessionIDs);
2076
+ const returnedSessionIDs = new Set(
2077
+ resolved.tickets.flatMap((t) => t.session_ids)
2078
+ );
2079
+ const resolvedSessionIDs = new Set(
2080
+ resolved.tickets.filter((t) => t.status === "resolved").flatMap((t) => t.session_ids)
2081
+ );
2082
+ const survivingSessions = sessionIDs.filter(
2083
+ (id) => returnedSessionIDs.has(id) && !resolvedSessionIDs.has(id)
2084
+ );
2085
+ if (survivingSessions.length !== sessionIDs.length) {
2086
+ this.trackedSessionIDs = survivingSessions;
2087
+ }
2088
+ const ticketIDs = resolved.tickets.filter((t) => t.status !== "resolved").map((t) => t.ticket_id);
2089
+ if (ticketIDs.length === 0) return { tickets: [] };
2090
+ const request = {
2091
+ agent_id: this.agentID,
2092
+ ticket_ids: ticketIDs
2093
+ };
2074
2094
  const response = await this.post(
2075
2095
  "/api/agent/poll",
2076
2096
  request
2077
2097
  );
2078
- const returnedIDs = new Set(response.tickets.map((t) => t.ticket_id));
2079
- const orphaned = ticketIDs.filter((id) => !returnedIDs.has(id));
2080
- if (orphaned.length > 0) {
2081
- this.trackedTicketIDs = this.trackedTicketIDs.filter(
2082
- (id) => !orphaned.includes(id)
2083
- );
2084
- }
2085
2098
  const knownCRIDs = /* @__PURE__ */ new Set();
2086
2099
  for (const ticket of response.tickets) {
2087
- if (ticket.status === "resolved") {
2088
- this.trackedTicketIDs = this.trackedTicketIDs.filter(
2089
- (id) => id !== ticket.ticket_id
2090
- );
2091
- }
2092
2100
  for (const cr of ticket.context_requests) {
2093
2101
  knownCRIDs.add(cr.id);
2094
2102
  if (!cr.is_active || this.respondedCRIDs.has(cr.id)) continue;
@@ -2114,13 +2122,17 @@ var PRBEAgent = class _PRBEAgent {
2114
2122
  }
2115
2123
  }
2116
2124
  /**
2117
- * Fetch ticket display info for all tracked tickets.
2125
+ * Fetch ticket display info for all tracked sessions.
2126
+ * Resolves session IDs → ticket IDs first, then fetches ticket info.
2118
2127
  */
2119
2128
  async fetchTicketInfo() {
2120
- const ticketIDs = this.trackedTicketIDs;
2121
- if (ticketIDs.length === 0) return [];
2122
- const request = { ticket_ids: ticketIDs };
2129
+ const sessionIDs = this.trackedSessionIDs;
2130
+ if (sessionIDs.length === 0) return [];
2123
2131
  try {
2132
+ const resolved = await this.resolveSessions(sessionIDs);
2133
+ const ticketIDs = resolved.tickets.map((t) => t.ticket_id);
2134
+ if (ticketIDs.length === 0) return [];
2135
+ const request = { ticket_ids: ticketIDs };
2124
2136
  const response = await this.post(
2125
2137
  "/api/agent/tickets",
2126
2138
  request
@@ -2138,7 +2150,7 @@ var PRBEAgent = class _PRBEAgent {
2138
2150
  }
2139
2151
  }
2140
2152
  resumePolling() {
2141
- if (this.trackedTicketIDs.length === 0) return;
2153
+ if (this.trackedSessionIDs.length === 0) return;
2142
2154
  this.startPolling();
2143
2155
  }
2144
2156
  /**
@@ -2161,7 +2173,7 @@ var PRBEAgent = class _PRBEAgent {
2161
2173
  this.state.completedInvestigations = [];
2162
2174
  this.state.activeCRs.clear();
2163
2175
  this.state.completedCRs = [];
2164
- this.state.trackedTicketIDs = [];
2176
+ this.state.trackedSessionIDs = [];
2165
2177
  this.state.ticketInfo = [];
2166
2178
  this.state.emit("status" /* STATUS */);
2167
2179
  }
@@ -2220,8 +2232,8 @@ var PRBEAgent = class _PRBEAgent {
2220
2232
  );
2221
2233
  this.currentInvestigationSource = "user" /* USER */;
2222
2234
  this.currentCRId = null;
2223
- if (result?.ticketId) {
2224
- this.addTrackedTicket(result.ticketId);
2235
+ if (result?.sessionId) {
2236
+ this.addTrackedSession(result.sessionId);
2225
2237
  }
2226
2238
  }
2227
2239
  // ---------- WebSocket Investigation ----------
@@ -2398,6 +2410,7 @@ var PRBEAgent = class _PRBEAgent {
2398
2410
  const report = msg.content ?? "";
2399
2411
  const userSummary = msg.metadata?.["user_summary"] ?? "";
2400
2412
  const ticketId2 = msg.metadata?.["ticket_id"];
2413
+ const sessionId = msg.metadata?.["session_id"];
2401
2414
  emit({
2402
2415
  type: "completed" /* COMPLETED */,
2403
2416
  report,
@@ -2405,7 +2418,7 @@ var PRBEAgent = class _PRBEAgent {
2405
2418
  ticketId: ticketId2
2406
2419
  });
2407
2420
  ws.close(1e3, "Complete");
2408
- finish({ report, userSummary, ticketId: ticketId2 });
2421
+ finish({ report, userSummary, ticketId: ticketId2, sessionId });
2409
2422
  break;
2410
2423
  }
2411
2424
  case "error" /* ERROR */:
@@ -2516,12 +2529,23 @@ var PRBEAgent = class _PRBEAgent {
2516
2529
  this.stopPolling();
2517
2530
  this.pollingTimer = setInterval(() => {
2518
2531
  void this.poll().then(() => {
2519
- if (this.trackedTicketIDs.length === 0) {
2532
+ if (this.trackedSessionIDs.length === 0) {
2520
2533
  this.stopPolling();
2521
2534
  }
2522
2535
  });
2523
2536
  }, this.config.pollingInterval);
2524
2537
  }
2538
+ // ---------- Session Resolution ----------
2539
+ async resolveSessions(sessionIDs) {
2540
+ const request = {
2541
+ agent_id: this.agentID,
2542
+ session_ids: sessionIDs
2543
+ };
2544
+ return this.post(
2545
+ "/api/agent/resolve-sessions",
2546
+ request
2547
+ );
2548
+ }
2525
2549
  // ---------- Networking ----------
2526
2550
  /**
2527
2551
  * Abort all in-flight fetch requests to prevent orphaned DNS lookups
@@ -2576,7 +2600,7 @@ var DEFAULT_PRBE_STATE = {
2576
2600
  completedInvestigations: [],
2577
2601
  activeCRs: [],
2578
2602
  completedCRs: [],
2579
- trackedTicketIDs: [],
2603
+ trackedSessionIDs: [],
2580
2604
  ticketInfo: [],
2581
2605
  hasActiveWork: false
2582
2606
  };
@@ -2620,7 +2644,7 @@ function serializePRBEState(state) {
2620
2644
  })),
2621
2645
  activeCRs: Array.from(state.activeCRs.values()).map(serializeCR),
2622
2646
  completedCRs: state.completedCRs.map(serializeCR),
2623
- trackedTicketIDs: state.trackedTicketIDs,
2647
+ trackedSessionIDs: state.trackedSessionIDs,
2624
2648
  ticketInfo: state.ticketInfo,
2625
2649
  hasActiveWork: state.hasActiveWork
2626
2650
  };