opencode-copilot-delegate 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ export type CancelTaskResult = {
2
+ cancelled: boolean;
3
+ error?: string;
4
+ };
5
+ export type CancelTaskRegistry = {
6
+ getTask: (taskId: string) => {
7
+ abortController: AbortController;
8
+ } | undefined;
9
+ };
10
+ export declare function cancelTaskById(taskRegistry: CancelTaskRegistry, taskId: string): CancelTaskResult;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import type { ParsedEvent } from './jsonl-parser';
9
9
  /** Status of a delegated Copilot task. */
10
- export type TaskStatus = 'running' | 'complete' | 'failed' | 'cancelled';
10
+ export type TaskStatus = 'running' | 'cancelling' | 'complete' | 'failed' | 'cancelled';
11
11
  /** Summary of a single tool call made during the Copilot session. */
12
12
  export type ToolCallSummary = {
13
13
  name: string;
@@ -27,7 +27,7 @@ export type NotifyClient = {
27
27
  };
28
28
  }) => Promise<unknown>;
29
29
  };
30
- tui: {
30
+ tui?: {
31
31
  showToast: (opts: {
32
32
  body: {
33
33
  message: string;
@@ -36,7 +36,14 @@ export type NotifyClient = {
36
36
  }) => unknown;
37
37
  };
38
38
  app: {
39
- log: (...args: unknown[]) => void;
39
+ log: (opts: {
40
+ body: {
41
+ service: string;
42
+ level: string;
43
+ message: string;
44
+ extra?: unknown;
45
+ };
46
+ }) => Promise<unknown>;
40
47
  };
41
48
  };
42
49
  /** Task information needed for building the notification. */
@@ -53,6 +60,7 @@ export type NotifyTaskInfo = {
53
60
  export declare function incrementInFlight(parentSessionID: string): void;
54
61
  /** Reset all counters (for testing only). */
55
62
  export declare function resetInFlightCounters(): void;
63
+ export declare function notifySpawn(client: NotifyClient, taskId: string): Promise<void>;
56
64
  /**
57
65
  * Notify the parent session that a Copilot delegation has completed.
58
66
  *
@@ -1,3 +1,6 @@
1
+ export declare function assertPluginStateDirNotSymlink(filePath: string): Promise<void>;
2
+ export declare function assertOrphansDirNotSymlink(filePath: string): Promise<void>;
3
+ export declare function readPidFileNoFollow(filePath: string): Promise<string>;
1
4
  export declare function resolveInstancePidFilePath(): string;
2
5
  export declare function appendPidEntry(filePath: string, pid: number, comm: string, lstart: string): Promise<void>;
3
6
  export declare function removePidEntry(filePath: string, pid: number): Promise<void>;
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ export declare const HealthResponseSchema: z.ZodObject<{
3
+ ok: z.ZodLiteral<true>;
4
+ version: z.ZodString;
5
+ }, z.core.$strict>;
6
+ export declare const TasksListResponseSchema: z.ZodObject<{
7
+ tasks: z.ZodArray<z.ZodObject<{
8
+ taskId: z.ZodString;
9
+ status: z.ZodEnum<{
10
+ running: "running";
11
+ cancelling: "cancelling";
12
+ complete: "complete";
13
+ failed: "failed";
14
+ cancelled: "cancelled";
15
+ }>;
16
+ agent: z.ZodString;
17
+ model: z.ZodString;
18
+ elapsedMs: z.ZodNumber;
19
+ toolCallCount: z.ZodNumber;
20
+ startedAt: z.ZodNumber;
21
+ }, z.core.$strict>>;
22
+ }, z.core.$strict>;
23
+ export declare const TasksCancelRequestSchema: z.ZodObject<{
24
+ taskId: z.ZodString;
25
+ }, z.core.$strict>;
26
+ export declare const TasksCancelResponseSchema: z.ZodObject<{
27
+ cancelled: z.ZodBoolean;
28
+ error: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>;
30
+ export declare const PortFileSchema: z.ZodObject<{
31
+ port: z.ZodNumber;
32
+ pid: z.ZodNumber;
33
+ token: z.ZodString;
34
+ }, z.core.$strict>;
35
+ export type HealthResponse = z.infer<typeof HealthResponseSchema>;
36
+ export type TasksListResponse = z.infer<typeof TasksListResponseSchema>;
37
+ export type TasksCancelRequest = z.infer<typeof TasksCancelRequestSchema>;
38
+ export type TasksCancelResponse = z.infer<typeof TasksCancelResponseSchema>;
39
+ export type PortFile = z.infer<typeof PortFileSchema>;
@@ -0,0 +1,32 @@
1
+ import type { AddressInfo } from 'node:net';
2
+ import type { CancelTaskResult } from './cancel-helper';
3
+ import type { TaskStatus } from './envelope';
4
+ import type { ParsedEvent } from './jsonl-parser';
5
+ type RpcTaskRecord = {
6
+ taskId: string;
7
+ status: TaskStatus;
8
+ agentName?: string;
9
+ modelName?: string;
10
+ startedAt: number;
11
+ endedAt?: number;
12
+ events?: ParsedEvent[];
13
+ };
14
+ type TaskRegistryLike = {
15
+ getAllTasks(): RpcTaskRecord[];
16
+ };
17
+ export type StartRpcServerOptions = {
18
+ taskRegistry: TaskRegistryLike;
19
+ cancelTaskById: (taskId: string) => CancelTaskResult | Promise<CancelTaskResult>;
20
+ portFileBaseDir?: string;
21
+ sessionDiscriminator?: string;
22
+ now?: () => number;
23
+ };
24
+ export type StartedRpcServer = {
25
+ port: number;
26
+ token: string;
27
+ close(): Promise<void>;
28
+ };
29
+ export declare function isMissingPathError(error: unknown): boolean;
30
+ export declare function getTcpServerPort(address: AddressInfo | string | null): number;
31
+ export declare function startRpcServer(options: StartRpcServerOptions): Promise<StartedRpcServer>;
32
+ export {};
@@ -2,6 +2,15 @@ import type { TaskStatus } from './envelope';
2
2
  export interface SetStatusOptions {
3
3
  pidFilePath?: string;
4
4
  }
5
+ /**
6
+ * Transition `task` to `newStatus`, enforcing the forward-only lifecycle.
7
+ *
8
+ * Idempotent on any terminal state (complete, failed, cancelled): once a task
9
+ * reaches a terminal status every subsequent call is a no-op. This prevents
10
+ * both terminal→terminal re-classification and terminal→non-terminal
11
+ * resurrection. When transitioning to a terminal state and `pidFilePath` is
12
+ * provided, the task's PID entry is removed from the orphan-reaper file.
13
+ */
5
14
  export declare function setStatus(task: {
6
15
  status: TaskStatus;
7
16
  pid: number;
@@ -0,0 +1,2 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ import type { TuiPluginApi } from '@opencode-ai/plugin/tui';
3
+ import type { RpcClient } from '../rpc-client';
4
+ import type { ModalListTask } from './row';
5
+ type ConfirmCardProps = {
6
+ Dialog: TuiPluginApi['ui']['Dialog'];
7
+ task: ModalListTask;
8
+ rpc: Pick<RpcClient, 'tasksCancel'>;
9
+ onConfirm: () => void;
10
+ onCancel: () => void;
11
+ onDismissAfterError: () => void;
12
+ };
13
+ export declare function ConfirmCard(props: ConfirmCardProps): any;
14
+ export default ConfirmCard;
@@ -0,0 +1,19 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ import type { TuiPluginApi } from '@opencode-ai/plugin/tui';
3
+ import type { RpcClient } from '../rpc-client';
4
+ import { type ModalListTask } from './row';
5
+ export type ModalListClock = {
6
+ now(): number;
7
+ setInterval(fn: () => void, delayMs: number): unknown;
8
+ clearInterval(handle: unknown): void;
9
+ };
10
+ type ModalListProps = {
11
+ Dialog: TuiPluginApi['ui']['Dialog'];
12
+ rpc: Pick<RpcClient, 'tasksList'>;
13
+ onClose: () => void;
14
+ onCancelTask?: (task: ModalListTask) => void;
15
+ initialTaskId?: string;
16
+ clock?: ModalListClock;
17
+ };
18
+ export declare function ModalList(props: ModalListProps): any;
19
+ export default ModalList;
@@ -0,0 +1,6 @@
1
+ import type { TasksListResponse } from '../../runtime/rpc-contract';
2
+ export type ModalListTask = TasksListResponse['tasks'][number];
3
+ export declare function displayValue(value: string): string;
4
+ export declare function formatElapsed(elapsedMs: number): string;
5
+ export declare function formatToolCalls(toolCallCount: number): string;
6
+ export declare function formatRowText(task: ModalListTask, nowMs: number): string;
@@ -0,0 +1,7 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ import type { TuiPlugin } from '@opencode-ai/plugin/tui';
3
+ declare const _default: {
4
+ id: string;
5
+ tui: TuiPlugin;
6
+ };
7
+ export default _default;