@getpaseo/plugin 0.15.4 → 0.16.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.
Files changed (40) hide show
  1. package/LICENSE +211 -0
  2. package/dist/client/client-state.d.ts +74 -6
  3. package/dist/client/client-state.js +48 -16
  4. package/dist/client/composer.d.ts +104 -0
  5. package/dist/client/composer.js +37 -0
  6. package/dist/client/contracts.d.ts +36 -4
  7. package/dist/client/host.d.ts +9 -3
  8. package/dist/client/host.js +7 -3
  9. package/dist/client/index.d.ts +11 -3
  10. package/dist/client/index.js +4 -2
  11. package/dist/client/new-workspace.d.ts +69 -0
  12. package/dist/client/new-workspace.js +17 -0
  13. package/dist/client/paseo-context.d.ts +5 -5
  14. package/dist/client/paseo-context.js +1 -1
  15. package/dist/client/query.d.ts +26 -0
  16. package/dist/client/query.js +84 -0
  17. package/dist/client/reference-api.d.ts +38 -0
  18. package/dist/client/reference-api.js +44 -0
  19. package/dist/client/refs.d.ts +28 -0
  20. package/dist/client/refs.js +22 -0
  21. package/dist/client/rpc-context.d.ts +23 -3
  22. package/dist/client/rpc-context.js +60 -4
  23. package/dist/client/runtime-context-bridge.js +11 -3
  24. package/dist/client/ui.d.ts +65 -0
  25. package/dist/contracts.d.ts +45 -0
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +1 -1
  28. package/dist/refs.d.ts +16 -0
  29. package/dist/refs.js +2 -0
  30. package/dist/rpc.d.ts +40 -1
  31. package/dist/rpc.js +37 -2
  32. package/dist/server/acp-internal/connection.js +66 -24
  33. package/dist/server/contracts.d.ts +19 -2
  34. package/dist/server/index.d.ts +1 -1
  35. package/dist/server/lifecycle.d.ts +24 -3
  36. package/dist/server/provider.d.ts +44 -1
  37. package/dist/server/provider.js +29 -1
  38. package/dist/settings.d.ts +2 -2
  39. package/dist/settings.js +2 -2
  40. package/package.json +6 -5
@@ -1,13 +1,17 @@
1
1
  import { PluginAttachmentSearchPayloadSchema } from "../attachments.js";
2
- export { PluginClientStateProvider } from "./client-state.js";
2
+ export { PluginClientStateProvider, usePaseoSelector, } from "./client-state.js";
3
+ export { PluginComposerProvider, PluginComposersProvider, } from "./composer.js";
4
+ export { PluginNewWorkspaceProvider } from "./new-workspace.js";
3
5
  export { usePluginRuntimeContextBridge, } from "./runtime-context-bridge.js";
4
6
  import { PluginRpcProvider } from "./rpc-context.js";
5
7
  import { PaseoApiProvider } from "./paseo-context.js";
6
- import { callPluginRpc } from "../rpc.js";
8
+ import { callPluginRpc, subscribePluginRpc } from "../rpc.js";
7
9
  export async function searchPluginAttachments(source, invoke, query) {
8
10
  const output = await callPluginRpc(source.search, invoke, { query });
9
11
  return PluginAttachmentSearchPayloadSchema.parseAsync(output);
10
12
  }
11
- export { callPluginRpc, PaseoApiProvider, PluginRpcProvider };
13
+ export { callPluginRpc, subscribePluginRpc, PaseoApiProvider, PluginRpcProvider };
12
14
  export { PluginTranslationRuntime, PluginTranslationProvider, usePluginTranslationRuntime, requirePluginText, isPluginMessage, } from "./translations.js";
15
+ export { createEntityRefs } from "./refs.js";
16
+ export { createPluginReferenceApi } from "./reference-api.js";
13
17
  //# sourceMappingURL=host.js.map
@@ -1,11 +1,16 @@
1
- export type { PluginHostProps, PluginTab, PluginPanelProps, PluginWorkspacePanelParams, PluginAgentPanelParams, PluginFilePanelParams, PluginAgentPanelContribution, PluginFilePanelContribution, PluginFilePanelProps, PluginSurfaceProps, PluginScreenProps, PluginPopoverProps, PluginScreenParams, PluginOpenScreenInput, PluginScreenLocation, PluginSidebarItemProps, PluginSidebarItemContribution, PluginIcon, PluginPanelLocation, PluginOpenPanelOptions, PluginWorkspacePanelProps, PluginAgentPanelProps, PluginClientOpenPanelOptions, PluginClientContext, PluginClientContribution, PluginWorkspacePanelContribution, PluginSettingsScreenContribution, PluginSurfaceContribution, PluginScreenContribution, PluginScreenTitle, PluginSidebarContribution, PluginTimelineTransformerContribution, PluginTimelineItemProps, PluginTimelineRendererContribution, PluginCommandCapabilities, PluginGlobalCommandContext, PluginWorkspaceCommandContext, PluginAgentCommandContext, PluginCommandCenterItemContribution, PluginClientSlashCommandContribution, SettingsState, } from "./contracts.js";
1
+ export type { PluginHostProps, PluginTab, PluginPanelProps, PluginWorkspacePanelParams, PluginAgentPanelParams, PluginFilePanelParams, PluginAgentPanelContribution, PluginFilePanelContribution, PluginFilePanelProps, PluginSurfaceProps, PluginScreenProps, PluginPopoverProps, PluginScreenParams, PluginOpenScreenInput, PluginScreenLocation, PluginSidebarItemProps, PluginSidebarViewProps, PluginSidebarViewContribution, PluginSidebarItemContribution, PluginIcon, PluginPanelLocation, PluginOpenPanelOptions, PluginWorkspacePanelProps, PluginAgentPanelProps, PluginClientOpenPanelOptions, PluginClientContext, PluginClientContribution, PluginWorkspacePanelContribution, PluginSettingsScreenContribution, PluginSurfaceContribution, PluginScreenContribution, PluginScreenTitle, PluginSidebarContribution, PluginTimelineTransformerContribution, PluginTimelineItemProps, PluginTimelineRendererContribution, PluginCommandCapabilities, PluginGlobalCommandContext, PluginWorkspaceCommandContext, PluginAgentCommandContext, PluginCommandCenterItemContribution, PluginClientSlashCommandContribution, SettingsState, } from "./contracts.js";
2
2
  export type { PluginButton, PluginButtonBehavior, PluginButtonContentProps, PluginButtonContext, PluginButtonIcon, PluginButtonIconProps, PluginButtonMenuEntry, PluginButtonRegistration, PluginComposerPillContribution, PluginHeaderButtonContribution, } from "./buttons.js";
3
3
  export type { PluginIconProps, PluginSerializableIcon, PluginSvgIcon } from "../icons.js";
4
4
  export type { PluginFile, PluginFileBytesState, PluginFileEvent, PluginFileTextState, PluginFileUrlState, PluginFileWriteOptions, } from "./file.js";
5
5
  export { PluginFileConflictError, PluginFileDeletedError, useFileBytes, useFileText, useFileUrl, } from "./file.js";
6
6
  export { usePaseo } from "./paseo-context.js";
7
- export { useAgent, useWorkspace } from "./client-state.js";
8
- export { useRpc } from "./rpc-context.js";
7
+ export { useAgent, useWorkspace, useProject, useTerminal, useWorkspaces, useAgents, useProjects, useTerminals, } from "./client-state.js";
8
+ export { useComposer, useComposers } from "./composer.js";
9
+ export type { PluginComposer, PluginComposerAttachment, PluginComposerFocusOptions, PluginComposerItemContribution, PluginComposerItemProps, PluginComposerSelector, } from "./composer.js";
10
+ export { useNewWorkspace } from "./new-workspace.js";
11
+ export type { PluginNewWorkspace, PluginNewWorkspaceItemContribution, PluginNewWorkspaceItemProps, } from "./new-workspace.js";
12
+ export { useRpc, useSubscription, type PluginSubscriptionState } from "./rpc-context.js";
13
+ export type { PluginSubscribeOptions, PluginSubscriptionClosed, PluginSubscriptionHandle, } from "../rpc.js";
9
14
  import type { SettingsDefinition } from "../settings.js";
10
15
  import type { SettingsState } from "./contracts.js";
11
16
  import type { ZodType } from "zod";
@@ -26,4 +31,7 @@ export { defineTranslations, useTranslation } from "./translations.js";
26
31
  export type { PluginI18n } from "./translations.js";
27
32
  export type { PluginText, PluginMessage, PluginTranslations } from "../text.js";
28
33
  export { useTabState } from "./tab.js";
34
+ export type { WorkspaceRef, AgentRef, ProjectRef, TerminalRef } from "../refs.js";
35
+ export type { Query, Group, GroupKey } from "./query.js";
36
+ export type { PluginPaseoApi, PluginProjectHandle, PluginTerminalHandle } from "./reference-api.js";
29
37
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,9 @@
1
1
  export { PluginFileConflictError, PluginFileDeletedError, useFileBytes, useFileText, useFileUrl, } from "./file.js";
2
2
  export { usePaseo } from "./paseo-context.js";
3
- export { useAgent, useWorkspace } from "./client-state.js";
4
- export { useRpc } from "./rpc-context.js";
3
+ export { useAgent, useWorkspace, useProject, useTerminal, useWorkspaces, useAgents, useProjects, useTerminals, } from "./client-state.js";
4
+ export { useComposer, useComposers } from "./composer.js";
5
+ export { useNewWorkspace } from "./new-workspace.js";
6
+ export { useRpc, useSubscription } from "./rpc-context.js";
5
7
  export { defineTranslations, useTranslation } from "./translations.js";
6
8
  export { useTabState } from "./tab.js";
7
9
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,69 @@
1
+ import { type ComponentType, type ReactNode } from "react";
2
+ import type { JsonValue } from "@getpaseo/protocol/agent-types";
3
+ import type { PluginHostProps } from "./contracts.js";
4
+ /**
5
+ * The New workspace setup the item sits in. `host` and `project` are the user's choices and are
6
+ * read-only. The commands change what the created workspace is built from, under the same rules as
7
+ * the screen's own pickers.
8
+ */
9
+ export interface PluginNewWorkspace {
10
+ readonly host: {
11
+ readonly id: string;
12
+ readonly label: string;
13
+ };
14
+ readonly project: {
15
+ readonly id: string;
16
+ readonly name: string;
17
+ } | null;
18
+ /** What the screen will create. A project that cannot make worktrees reads `"local"`. */
19
+ readonly isolation: "local" | "worktree";
20
+ /**
21
+ * What a new worktree starts from; `null` until the project's default is known. A branch's
22
+ * `name` is the exact ref creation uses, such as `refs/remotes/origin/main`, so
23
+ * `setBaseRef(newWorkspace.baseRef)` changes nothing.
24
+ */
25
+ readonly baseRef: {
26
+ readonly type: "branch";
27
+ readonly name: string;
28
+ } | {
29
+ readonly type: "change-request";
30
+ readonly number: number;
31
+ } | null;
32
+ /**
33
+ * The name of the branch a new worktree is created on; `null` lets Paseo pick one. It is kept
34
+ * while isolation is local or the base is a change request. It names the new branch of any
35
+ * worktree that cuts one, from the default base or a chosen branch, and does not apply to a
36
+ * worktree that checks out an existing branch or change request.
37
+ */
38
+ readonly branch: string | null;
39
+ /** The workspace's metadata, not the first agent's. */
40
+ readonly metadata: Readonly<Record<string, JsonValue>>;
41
+ /** Rejects `"worktree"` for a project that cannot make worktrees. */
42
+ setIsolation(isolation: "local" | "worktree"): Promise<void>;
43
+ /**
44
+ * Starts the workspace from a branch. `name` is any ref the Base picker offers, such as
45
+ * `refs/remotes/origin/main`, or a bare branch name, which Paseo resolves the way it does for
46
+ * a branch name it is given anywhere else. Rejects while no project is chosen.
47
+ */
48
+ setBaseRef(ref: {
49
+ type: "branch";
50
+ name: string;
51
+ }): Promise<void>;
52
+ setBranch(name: string | null): Promise<void>;
53
+ /** Top-level keys replace; `null` removes the key. Rejects on a host without metadata support. */
54
+ setMetadata(patch: Record<string, JsonValue>): Promise<void>;
55
+ }
56
+ export interface PluginNewWorkspaceItemProps extends PluginHostProps {
57
+ }
58
+ export interface PluginNewWorkspaceItemContribution {
59
+ id: string;
60
+ Component: ComponentType<PluginNewWorkspaceItemProps>;
61
+ }
62
+ export declare function PluginNewWorkspaceProvider({ newWorkspace, children, }: {
63
+ newWorkspace: PluginNewWorkspace;
64
+ children: ReactNode;
65
+ }): import("react/jsx-runtime").JSX.Element;
66
+ export declare function usePluginNewWorkspaceValue(): PluginNewWorkspace | null;
67
+ /** The New workspace setup this item sits in. Call it from a component registered with `addNewWorkspaceItem`. */
68
+ export declare function useNewWorkspace(): PluginNewWorkspace;
69
+ //# sourceMappingURL=new-workspace.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const PluginNewWorkspaceContext = createContext(null);
4
+ export function PluginNewWorkspaceProvider({ newWorkspace, children, }) {
5
+ return (_jsx(PluginNewWorkspaceContext.Provider, { value: newWorkspace, children: children }));
6
+ }
7
+ export function usePluginNewWorkspaceValue() {
8
+ return useContext(PluginNewWorkspaceContext);
9
+ }
10
+ /** The New workspace setup this item sits in. Call it from a component registered with `addNewWorkspaceItem`. */
11
+ export function useNewWorkspace() {
12
+ const newWorkspace = useContext(PluginNewWorkspaceContext);
13
+ if (!newWorkspace)
14
+ throw new Error("useNewWorkspace must run inside a New workspace item");
15
+ return newWorkspace;
16
+ }
17
+ //# sourceMappingURL=new-workspace.js.map
@@ -1,9 +1,9 @@
1
- import type { PaseoApi } from "@getpaseo/client";
1
+ import type { PluginPaseoApi } from "./reference-api.js";
2
2
  import { type ReactNode } from "react";
3
- export declare function usePaseoContextValue(): PaseoApi | null;
4
- export declare function PaseoApiProvider({ children, paseo }: {
3
+ export declare function usePaseoContextValue(): PluginPaseoApi | null;
4
+ export declare function PaseoApiProvider({ children, paseo, }: {
5
5
  children: ReactNode;
6
- paseo: PaseoApi;
6
+ paseo: PluginPaseoApi;
7
7
  }): import("react/jsx-runtime").JSX.Element;
8
- export declare function usePaseo(): PaseoApi;
8
+ export declare function usePaseo(): PluginPaseoApi;
9
9
  //# sourceMappingURL=paseo-context.d.ts.map
@@ -4,7 +4,7 @@ const PaseoApiContext = createContext(null);
4
4
  export function usePaseoContextValue() {
5
5
  return useContext(PaseoApiContext);
6
6
  }
7
- export function PaseoApiProvider({ children, paseo }) {
7
+ export function PaseoApiProvider({ children, paseo, }) {
8
8
  return _jsx(PaseoApiContext.Provider, { value: paseo, children: children });
9
9
  }
10
10
  export function usePaseo() {
@@ -0,0 +1,26 @@
1
+ interface GroupDescriptor {
2
+ readonly key: string;
3
+ readonly title?: string;
4
+ readonly color?: string;
5
+ }
6
+ export type GroupKey = string | GroupDescriptor;
7
+ export interface Query<Snapshot> {
8
+ readonly hosts?: readonly string[];
9
+ readonly where?: (item: Snapshot) => boolean;
10
+ readonly orderBy?: keyof Snapshot | readonly [keyof Snapshot, "asc" | "desc"] | ((a: Snapshot, b: Snapshot) => number);
11
+ readonly groupBy?: (item: Snapshot) => GroupKey | readonly GroupKey[];
12
+ }
13
+ export interface Group<Ref> {
14
+ readonly key: string;
15
+ readonly title: string | null;
16
+ readonly color: string | null;
17
+ readonly items: readonly Ref[];
18
+ }
19
+ interface Referenced {
20
+ readonly hostId: string;
21
+ readonly ref: unknown;
22
+ }
23
+ /** A hook owns one projection; sharing survives both source and query changes. */
24
+ export declare function createCollectionQuery<Snapshot extends Referenced>(): (snapshots: readonly Snapshot[], query?: Query<Snapshot>) => readonly Snapshot["ref"][] | readonly Group<Snapshot["ref"]>[];
25
+ export {};
26
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1,84 @@
1
+ function groupKeys(value) {
2
+ if (typeof value === "string")
3
+ return [value];
4
+ if ("key" in value)
5
+ return [value];
6
+ return value;
7
+ }
8
+ function sameSequence(left, right) {
9
+ return left.length === right.length && left.every((item, index) => item === right[index]);
10
+ }
11
+ function compareValues(left, right, direction) {
12
+ if (Object.is(left, right))
13
+ return 0;
14
+ if (left === null || left === undefined)
15
+ return 1;
16
+ if (right === null || right === undefined)
17
+ return -1;
18
+ if (typeof left === "number" && typeof right === "number")
19
+ return (left - right) * direction;
20
+ return String(left).localeCompare(String(right)) * direction;
21
+ }
22
+ /** A hook owns one projection; sharing survives both source and query changes. */
23
+ export function createCollectionQuery() {
24
+ let previousItems = Object.freeze([]);
25
+ let previousGroups = Object.freeze([]);
26
+ return function project(snapshots, query = {}) {
27
+ const items = snapshots.filter((item) => {
28
+ if (query.hosts && !query.hosts.includes(item.hostId))
29
+ return false;
30
+ return !query.where || query.where(item);
31
+ });
32
+ const order = query.orderBy;
33
+ if (typeof order === "function")
34
+ items.sort(order);
35
+ else if (order !== undefined) {
36
+ const field = typeof order === "object" ? order[0] : order;
37
+ const direction = typeof order === "object" && order[1] === "desc" ? -1 : 1;
38
+ items.sort((a, b) => compareValues(a[field], b[field], direction));
39
+ }
40
+ if (!query.groupBy) {
41
+ const refs = items.map((item) => item.ref);
42
+ if (!sameSequence(previousItems, refs))
43
+ previousItems = Object.freeze(refs);
44
+ return previousItems;
45
+ }
46
+ const groups = new Map();
47
+ for (const item of items) {
48
+ const grouping = query.groupBy(item);
49
+ const keys = groupKeys(grouping);
50
+ const seen = new Set();
51
+ for (const value of keys) {
52
+ const descriptor = typeof value === "string" ? { key: value } : value;
53
+ if (seen.has(descriptor.key))
54
+ continue;
55
+ seen.add(descriptor.key);
56
+ let group = groups.get(descriptor.key);
57
+ if (!group) {
58
+ group = {
59
+ key: descriptor.key,
60
+ title: descriptor.title ?? null,
61
+ color: descriptor.color ?? null,
62
+ items: [],
63
+ };
64
+ groups.set(descriptor.key, group);
65
+ }
66
+ group.items.push(item.ref);
67
+ }
68
+ }
69
+ const oldGroups = new Map(previousGroups.map((group) => [group.key, group]));
70
+ const nextGroups = Array.from(groups.values(), (group) => {
71
+ const previous = oldGroups.get(group.key);
72
+ if (previous &&
73
+ previous.title === group.title &&
74
+ previous.color === group.color &&
75
+ sameSequence(previous.items, group.items))
76
+ return previous;
77
+ return Object.freeze({ ...group, items: Object.freeze(group.items) });
78
+ });
79
+ if (!sameSequence(previousGroups, nextGroups))
80
+ previousGroups = Object.freeze(nextGroups);
81
+ return previousGroups;
82
+ };
83
+ }
84
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1,38 @@
1
+ import type { PaseoApi, PaseoAgent, PaseoAgentHandle, PaseoWorkspace, PaseoWorkspaceHandle, PaseoWorkspaceCreateOptions } from "@getpaseo/client";
2
+ import type { PaseoTerminal, PaseoTerminalHandle } from "@getpaseo/client";
3
+ import type { PluginProjectSnapshot } from "../contracts.js";
4
+ import type { AgentRef, ProjectRef, TerminalRef, WorkspaceRef } from "../refs.js";
5
+ import type { PluginSidebarViewProps } from "./contracts.js";
6
+ export interface PluginProjectHandle {
7
+ readonly ref: ProjectRef;
8
+ open(): void;
9
+ createWorkspace(input?: Omit<PaseoWorkspaceCreateOptions, "source"> & {
10
+ source?: PaseoWorkspaceCreateOptions["source"];
11
+ }): Promise<PaseoWorkspaceHandle>;
12
+ }
13
+ export interface PluginTerminalHandle extends PaseoTerminalHandle {
14
+ focus(): void;
15
+ }
16
+ export interface PluginPaseoApi extends PaseoApi {
17
+ workspaces: Omit<PaseoApi["workspaces"], "ref"> & {
18
+ ref(workspace: string | PaseoWorkspace | WorkspaceRef): PaseoWorkspaceHandle;
19
+ };
20
+ agents: Omit<PaseoApi["agents"], "ref"> & {
21
+ ref(agent: string | PaseoAgent | AgentRef): PaseoAgentHandle;
22
+ };
23
+ projects: PaseoApi["projects"] & {
24
+ ref(project: ProjectRef): PluginProjectHandle;
25
+ };
26
+ terminals: Omit<PaseoApi["terminals"], "ref"> & {
27
+ ref(terminal: TerminalRef): PluginTerminalHandle;
28
+ ref(terminal: string | PaseoTerminal): PaseoTerminalHandle;
29
+ };
30
+ }
31
+ /** Host adapter; the installation retains its single API identity across every surface. */
32
+ export declare function createPluginReferenceApi(input: {
33
+ paseo: PaseoApi;
34
+ resolveHost(hostId: string): PaseoApi;
35
+ readProject(ref: ProjectRef): PluginProjectSnapshot | null;
36
+ navigation: PluginSidebarViewProps["navigation"];
37
+ }): PluginPaseoApi;
38
+ //# sourceMappingURL=reference-api.d.ts.map
@@ -0,0 +1,44 @@
1
+ /** Host adapter; the installation retains its single API identity across every surface. */
2
+ export function createPluginReferenceApi(input) {
3
+ const { paseo } = input;
4
+ const workspaceRef = paseo.workspaces.ref;
5
+ const agentRef = paseo.agents.ref;
6
+ const terminalRef = paseo.terminals.ref;
7
+ function refWorkspace(workspace) {
8
+ if (typeof workspace !== "string" && "hostId" in workspace)
9
+ return input.resolveHost(workspace.hostId).workspaces.ref(workspace.id);
10
+ return workspaceRef(workspace);
11
+ }
12
+ function refAgent(agent) {
13
+ if (typeof agent !== "string" && "hostId" in agent)
14
+ return input.resolveHost(agent.hostId).agents.ref(agent.id);
15
+ return agentRef(agent);
16
+ }
17
+ function terminal(ref) {
18
+ if (typeof ref !== "string" && "hostId" in ref) {
19
+ const handle = input.resolveHost(ref.hostId).terminals.ref(ref.id);
20
+ return Object.assign(handle, { focus: () => input.navigation.openTerminal(ref) });
21
+ }
22
+ return terminalRef(ref);
23
+ }
24
+ function project(ref) {
25
+ return {
26
+ ref,
27
+ open: () => input.navigation.openProject(ref),
28
+ async createWorkspace(options = {}) {
29
+ const snapshot = input.readProject(ref);
30
+ if (!snapshot)
31
+ throw new Error("Project is no longer available");
32
+ const source = options.source ?? { kind: "directory", path: snapshot.rootPath };
33
+ return input.resolveHost(ref.hostId).workspaces.create({ ...options, source });
34
+ },
35
+ };
36
+ }
37
+ return Object.assign(paseo, {
38
+ workspaces: Object.assign(paseo.workspaces, { ref: refWorkspace }),
39
+ agents: Object.assign(paseo.agents, { ref: refAgent }),
40
+ projects: Object.assign(paseo.projects, { ref: project }),
41
+ terminals: Object.assign(paseo.terminals, { ref: terminal }),
42
+ });
43
+ }
44
+ //# sourceMappingURL=reference-api.js.map
@@ -0,0 +1,28 @@
1
+ /** Owned by the app session, shared by every plugin installation. */
2
+ export declare function createEntityRefs(): {
3
+ workspace: (hostId: string, id: string) => Readonly<{
4
+ kind: "workspace";
5
+ key: string;
6
+ hostId: string;
7
+ id: string;
8
+ }>;
9
+ agent: (hostId: string, id: string) => Readonly<{
10
+ kind: "agent";
11
+ key: string;
12
+ hostId: string;
13
+ id: string;
14
+ }>;
15
+ project: (hostId: string, id: string) => Readonly<{
16
+ kind: "project";
17
+ key: string;
18
+ hostId: string;
19
+ id: string;
20
+ }>;
21
+ terminal: (hostId: string, id: string) => Readonly<{
22
+ kind: "terminal";
23
+ key: string;
24
+ hostId: string;
25
+ id: string;
26
+ }>;
27
+ };
28
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** Owned by the app session, shared by every plugin installation. */
2
+ export function createEntityRefs() {
3
+ function intern(kind) {
4
+ const references = new Map();
5
+ return function reference(hostId, id) {
6
+ const key = JSON.stringify([hostId, id]);
7
+ let ref = references.get(key);
8
+ if (!ref) {
9
+ ref = Object.freeze({ kind, key, hostId, id });
10
+ references.set(key, ref);
11
+ }
12
+ return ref;
13
+ };
14
+ }
15
+ return {
16
+ workspace: intern("workspace"),
17
+ agent: intern("agent"),
18
+ project: intern("project"),
19
+ terminal: intern("terminal"),
20
+ };
21
+ }
22
+ //# sourceMappingURL=refs.js.map
@@ -1,13 +1,33 @@
1
1
  import { type ReactNode } from "react";
2
2
  import type { ZodType, input as ZodInput, output as ZodOutput } from "zod";
3
- import { type PluginRpcContract } from "../rpc.js";
3
+ import { type PluginRpcContract, type PluginSubscriptionContract, type PluginSubscriptionHandle, type PluginSubscriptionObserver, type PluginWireInput } from "../rpc.js";
4
+ export type PluginSubscribe = (method: string, input: unknown, observer: PluginSubscriptionObserver) => PluginSubscriptionHandle;
4
5
  export interface PluginRpcContextValue {
5
6
  invoke(method: string, input: unknown): Promise<unknown>;
7
+ subscribe: PluginSubscribe;
6
8
  }
7
9
  export declare function usePluginRpcContextValue(): PluginRpcContextValue | null;
8
- export declare function PluginRpcProvider({ children, invoke, }: {
10
+ export declare function PluginRpcProvider({ children, invoke, subscribe, }: {
9
11
  children: ReactNode;
10
12
  invoke(method: string, input: unknown): Promise<unknown>;
13
+ subscribe: PluginSubscribe;
11
14
  }): import("react/jsx-runtime").JSX.Element;
12
- export declare function useRpc<InputSchema extends ZodType, OutputSchema extends ZodType>(contract: PluginRpcContract<InputSchema, OutputSchema>): (input: ZodInput<InputSchema>) => Promise<ZodOutput<OutputSchema>>;
15
+ export declare function useRpc<InputSchema extends ZodType, OutputSchema extends ZodType>(contract: PluginRpcContract<InputSchema, OutputSchema>): (input: PluginWireInput<ZodInput<InputSchema>>) => Promise<ZodOutput<OutputSchema>>;
16
+ export type PluginSubscriptionState = {
17
+ status: "connecting";
18
+ } | {
19
+ status: "live";
20
+ }
21
+ /** The plugin's handler finished. The hook subscribes again when `input` changes. */
22
+ | {
23
+ status: "closed";
24
+ } | {
25
+ status: "error";
26
+ error: Error;
27
+ };
28
+ /**
29
+ * Subscribes while the component is mounted. Re-subscribes when `input` changes by shallow
30
+ * comparison; `onEvent` always runs the latest callback.
31
+ */
32
+ export declare function useSubscription<InputSchema extends ZodType, EventSchema extends ZodType>(contract: PluginSubscriptionContract<InputSchema, EventSchema>, input: PluginWireInput<ZodInput<InputSchema>>, onEvent: (event: ZodOutput<EventSchema>) => void): PluginSubscriptionState;
13
33
  //# sourceMappingURL=rpc-context.d.ts.map
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useCallback, useContext, useMemo } from "react";
3
- import { callPluginRpc } from "../rpc.js";
2
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
3
+ import { callPluginRpc, subscribePluginRpc, } from "../rpc.js";
4
+ import { shallowEqual } from "./shallow.js";
4
5
  const PluginRpcContext = createContext(null);
5
6
  export function usePluginRpcContextValue() {
6
7
  return useContext(PluginRpcContext);
7
8
  }
8
- export function PluginRpcProvider({ children, invoke, }) {
9
- const value = useMemo(() => ({ invoke }), [invoke]);
9
+ export function PluginRpcProvider({ children, invoke, subscribe, }) {
10
+ const value = useMemo(() => ({ invoke, subscribe }), [invoke, subscribe]);
10
11
  return _jsx(PluginRpcContext.Provider, { value: value, children: children });
11
12
  }
12
13
  export function useRpc(contract) {
@@ -15,4 +16,59 @@ export function useRpc(contract) {
15
16
  throw new Error("useRpc must run inside a contributed plugin surface");
16
17
  return useCallback((input) => callPluginRpc(contract, context.invoke, input), [context, contract]);
17
18
  }
19
+ /**
20
+ * Subscribes while the component is mounted. Re-subscribes when `input` changes by shallow
21
+ * comparison; `onEvent` always runs the latest callback.
22
+ */
23
+ export function useSubscription(contract, input, onEvent) {
24
+ const context = usePluginRpcContextValue();
25
+ if (!context)
26
+ throw new Error("useSubscription must run inside a contributed plugin surface");
27
+ const subscribe = context.subscribe;
28
+ const onEventRef = useRef(onEvent);
29
+ onEventRef.current = onEvent;
30
+ const stableInput = useShallowStable(input);
31
+ const [state, setState] = useState({ status: "connecting" });
32
+ useEffect(() => {
33
+ let active = true;
34
+ setState({ status: "connecting" });
35
+ let handle;
36
+ try {
37
+ handle = subscribePluginRpc(contract, subscribe, stableInput, (event) => onEventRef.current(event), {
38
+ onClosed: ({ error }) => {
39
+ if (active)
40
+ setState(error ? { status: "error", error } : CLOSED);
41
+ },
42
+ });
43
+ }
44
+ catch (error) {
45
+ setState({ status: "error", error: toError(error) });
46
+ return;
47
+ }
48
+ handle.ready.then(() => {
49
+ if (active)
50
+ setState((current) => (current.status === "connecting" ? LIVE : current));
51
+ return undefined;
52
+ }, (error) => {
53
+ if (active)
54
+ setState({ status: "error", error: toError(error) });
55
+ });
56
+ return () => {
57
+ active = false;
58
+ handle();
59
+ };
60
+ }, [contract, subscribe, stableInput]);
61
+ return state;
62
+ }
63
+ const LIVE = { status: "live" };
64
+ const CLOSED = { status: "closed" };
65
+ function useShallowStable(value) {
66
+ const ref = useRef(value);
67
+ if (!shallowEqual(ref.current, value))
68
+ ref.current = value;
69
+ return ref.current;
70
+ }
71
+ function toError(error) {
72
+ return error instanceof Error ? error : new Error(String(error));
73
+ }
18
74
  //# sourceMappingURL=rpc-context.js.map
@@ -1,7 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { PluginTranslationProvider, usePluginTranslationRuntime } from "./translations.js";
3
3
  import { useCallback } from "react";
4
+ import { PluginComposerProvider, PluginComposersProvider, usePluginComposerValue, usePluginComposersSource, } from "./composer.js";
4
5
  import { PluginClientStateProvider, usePluginClientStateSource } from "./client-state.js";
6
+ import { PluginNewWorkspaceProvider, usePluginNewWorkspaceValue } from "./new-workspace.js";
5
7
  import { PaseoApiProvider, usePaseoContextValue } from "./paseo-context.js";
6
8
  import { PluginRpcProvider, usePluginRpcContextValue } from "./rpc-context.js";
7
9
  /** Rebuilds plugin runtime contexts inside React Native portal hosts. */
@@ -10,12 +12,18 @@ export function usePluginRuntimeContextBridge() {
10
12
  const paseo = usePaseoContextValue();
11
13
  const rpc = usePluginRpcContextValue();
12
14
  const state = usePluginClientStateSource();
15
+ const composer = usePluginComposerValue();
16
+ const composers = usePluginComposersSource();
17
+ const newWorkspace = usePluginNewWorkspaceValue();
13
18
  if (!paseo || !rpc) {
14
19
  throw new Error("Plugin UI must run inside a contributed plugin surface");
15
20
  }
16
21
  return useCallback((children) => {
17
- const content = state ? (_jsx(PluginClientStateProvider, { source: state, children: children })) : (children);
18
- return (_jsx(PaseoApiProvider, { paseo: paseo, children: _jsx(PluginRpcProvider, { invoke: rpc.invoke, children: _jsx(PluginTranslationProvider, { runtime: translations, children: content }) }) }));
19
- }, [paseo, rpc, state, translations]);
22
+ const withState = state ? (_jsx(PluginClientStateProvider, { source: state, children: children })) : (children);
23
+ const withComposers = composers ? (_jsx(PluginComposersProvider, { source: composers, children: withState })) : (withState);
24
+ const withNewWorkspace = newWorkspace ? (_jsx(PluginNewWorkspaceProvider, { newWorkspace: newWorkspace, children: withComposers })) : (withComposers);
25
+ const content = composer ? (_jsx(PluginComposerProvider, { composer: composer, children: withNewWorkspace })) : (withNewWorkspace);
26
+ return (_jsx(PaseoApiProvider, { paseo: paseo, children: _jsx(PluginRpcProvider, { invoke: rpc.invoke, subscribe: rpc.subscribe, children: _jsx(PluginTranslationProvider, { runtime: translations, children: content }) }) }));
27
+ }, [composer, composers, newWorkspace, paseo, rpc, state, translations]);
20
28
  }
21
29
  //# sourceMappingURL=runtime-context-bridge.js.map
@@ -156,4 +156,69 @@ export interface MarkdownProps {
156
156
  }
157
157
  /** Renders Markdown using Paseo’s theme, selection, and link behavior. */
158
158
  export declare const Markdown: ComponentType<MarkdownProps>;
159
+ export interface ComposerControlProps {
160
+ /** The control's label and tooltip. */
161
+ title: string;
162
+ /** A Lucide icon name, inline SVG, or a component. */
163
+ icon: PluginIcon;
164
+ disabled?: boolean;
165
+ }
166
+ /**
167
+ * What a control's callback receives. A returned promise marks the control pending until it
168
+ * settles, and Paseo reports a rejection to the user.
169
+ */
170
+ export interface ToggleProps extends ComposerControlProps {
171
+ value: boolean;
172
+ onValueChange(event: {
173
+ value: boolean;
174
+ }): void | Promise<void>;
175
+ }
176
+ export interface SelectProps<Value extends string = string> extends ComposerControlProps {
177
+ value: Value;
178
+ options: readonly {
179
+ value: Value;
180
+ label: string;
181
+ description?: string;
182
+ }[];
183
+ onValueChange(event: {
184
+ value: Value;
185
+ }): void | Promise<void>;
186
+ }
187
+ export interface ActionPressEvent {
188
+ }
189
+ export interface ActionProps extends ComposerControlProps {
190
+ onPress(event: ActionPressEvent): void | Promise<void>;
191
+ }
192
+ /** One result of a `Combobox` search. Extra fields ride along to `onSelect`. */
193
+ export interface ComboboxItem {
194
+ id: string;
195
+ label: string;
196
+ description?: string;
197
+ }
198
+ export interface ComboboxSearchEvent {
199
+ /** Empty when the list opens. */
200
+ query: string;
201
+ }
202
+ export interface ComboboxProps<Item extends ComboboxItem = ComboboxItem> extends ComposerControlProps {
203
+ /** What the control shows. It need not be among the search results. */
204
+ value: ComboboxItem | null;
205
+ /**
206
+ * Called when the list opens and again, debounced, as the user types. Paseo shows the loading
207
+ * and error states, keeps the previous results while a search runs, and ignores a search that a
208
+ * newer one replaced.
209
+ */
210
+ search(event: ComboboxSearchEvent): Promise<readonly Item[]>;
211
+ onSelect(event: {
212
+ item: Item;
213
+ }): void | Promise<void>;
214
+ }
215
+ /**
216
+ * Paseo's controls. Render them from a composer item's or a New workspace item's `Component`.
217
+ * Paseo draws them where the item sits: inline when the composer has room and as rows in its
218
+ * overflow sheet when it does not, and as a field in the New workspace setup.
219
+ */
220
+ export declare const Toggle: ComponentType<ToggleProps>;
221
+ export declare function Select<Value extends string>(props: SelectProps<Value>): ReactNode;
222
+ export declare const Action: ComponentType<ActionProps>;
223
+ export declare function Combobox<Item extends ComboboxItem>(props: ComboboxProps<Item>): ReactNode;
159
224
  //# sourceMappingURL=ui.d.ts.map