@howaboua/pi-shepherdr 0.2.12 → 0.2.14

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.
@@ -10,7 +10,11 @@ import type {
10
10
  } from "@howaboua/pi-codex-conversion/context-sharing";
11
11
  import { Check } from "typebox/value";
12
12
  import { AgentAttachment } from "./attachment.js";
13
- import { Identity } from "./attachment-protocol.js";
13
+ import {
14
+ attachmentOwner,
15
+ attachmentRoutes,
16
+ Identity,
17
+ } from "./attachment-protocol.js";
14
18
  import type { AgentBoard } from "./board/host.js";
15
19
  import { isBoardEnvelope } from "./board/protocol.js";
16
20
  import type { AgentFleet, ConnectedMachine } from "./fleet.js";
@@ -82,7 +86,7 @@ export class SharedAgentContext {
82
86
  value.operation === "attachment-export-notes" ||
83
87
  value.operation === "detach-commit")
84
88
  )
85
- return this.attachment.target.handle(ctx, value);
89
+ return this.attachment.target.handle(ctx, value, signal);
86
90
  const service = this.getService();
87
91
  const identity = service?.describe(ctx);
88
92
  if (
@@ -311,12 +315,46 @@ export async function registerSharedAgentContext(
311
315
  close = undefined;
312
316
  unregister?.();
313
317
  unregister = connection?.service?.registerRouter(
314
- async (context, request, signal) =>
315
- shared.handle(
316
- context,
317
- { operation: "context", request, visited: [] },
318
- signal,
319
- ) as Promise<SharedContextResult>,
318
+ Object.assign(
319
+ async (
320
+ context: ExtensionContext,
321
+ request: SharedContextRequest,
322
+ signal?: AbortSignal,
323
+ ) => {
324
+ const attached = await shared.attachment.routing.route(
325
+ context,
326
+ request,
327
+ [],
328
+ (route, next) =>
329
+ fleet
330
+ .connected(route.machine)
331
+ .client.requestContext(
332
+ sessionContextPath(route.sessionFile),
333
+ next,
334
+ signal,
335
+ ),
336
+ signal,
337
+ );
338
+ if (attached) return attached;
339
+ if (connection?.service?.describe(context)?.storage === "remote")
340
+ return undefined;
341
+ return shared.handle(
342
+ context,
343
+ { operation: "context", request, visited: [] },
344
+ signal,
345
+ ) as Promise<SharedContextResult>;
346
+ },
347
+ {
348
+ requiresRemoteScope: (context: ExtensionContext) =>
349
+ attachmentOwner(context)?.context?.controller.storage ===
350
+ "remote" ||
351
+ attachmentRoutes(context).some(
352
+ (route) =>
353
+ route.phase === "ready" &&
354
+ route.plan.context?.target.storage === "remote",
355
+ ),
356
+ },
357
+ ),
320
358
  );
321
359
  const file = ctx.sessionManager.getSessionFile();
322
360
  if (file)
package/src/types.ts CHANGED
@@ -78,6 +78,7 @@ export interface MonitoredAgent {
78
78
  readonly activity: AgentActivity;
79
79
  readonly cwd?: string;
80
80
  readonly lastAssistantId?: string;
81
+ readonly lastQuestionId?: string;
81
82
  readonly name?: string;
82
83
  readonly paneId: string;
83
84
  readonly tabId: string;
@@ -119,6 +120,7 @@ export interface LatestInput {
119
120
  }
120
121
 
121
122
  export interface PendingAsk {
123
+ delivery?: "steer";
122
124
  handoff: boolean;
123
125
  prompts: Array<{
124
126
  body?: string;