@andrioid/paseo-attention-span 0.3.2 → 0.3.4
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/client/attention-screen.tsx +8 -4
- package/client/coverage-settings.tsx +3 -16
- package/client/feedback.tsx +2 -1
- package/client/sessions.ts +9 -27
- package/docs/architecture.md +2 -2
- package/index.client.tsx +5 -15
- package/index.server.ts +3 -0
- package/package.json +1 -1
- package/requirements.yaml +0 -1
- package/shared/providers.ts +69 -0
- package/shared/rpc.ts +3 -0
- package/client/host.ts +0 -8
|
@@ -18,7 +18,7 @@ import { NextUpList } from "./next-up";
|
|
|
18
18
|
import { agentSignal, sessionEntry, startAnotherEntry } from "./session-menu";
|
|
19
19
|
import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
|
|
20
20
|
import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
|
|
21
|
-
import { branchWorkspaces, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
21
|
+
import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
|
|
22
22
|
import { SetupChecklist } from "./setup";
|
|
23
23
|
import { Avatar, Button, KeepStyles, Loading, Meta, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStyles } from "./ui";
|
|
24
24
|
|
|
@@ -202,6 +202,8 @@ function AttentionList({
|
|
|
202
202
|
const fetchDetails = useRpc(rpc.itemDetails);
|
|
203
203
|
const setCodeRepo = useRpc(rpc.setCodeRepo);
|
|
204
204
|
const fetchDefaultBranch = useRpc(rpc.defaultBranch);
|
|
205
|
+
const fetchReadyProviders = useRpc(rpc.readyProviders);
|
|
206
|
+
const fetchProviders: FetchProviders = () => fetchReadyProviders({}).then((result) => result.providers);
|
|
205
207
|
const defaultBranch: DefaultBranch = async (repo) => (await fetchDefaultBranch({ repo })).name;
|
|
206
208
|
const [tab, setTab] = useState<TabId>("doing");
|
|
207
209
|
// Every card with a change still running: each runs on its own.
|
|
@@ -263,7 +265,7 @@ function AttentionList({
|
|
|
263
265
|
await before?.();
|
|
264
266
|
const { context } = await fetchContext({ kind, target });
|
|
265
267
|
const prompt = renderPrompt(kind, target, context, config);
|
|
266
|
-
await started(await startSession(paseo, { itemKey, kind, target, prompt, config, checkout }));
|
|
268
|
+
await started(await startSession(paseo, { itemKey, kind, target, prompt, config, fetchProviders, checkout }));
|
|
267
269
|
}
|
|
268
270
|
|
|
269
271
|
function place(codeRepo: string) {
|
|
@@ -320,6 +322,7 @@ function AttentionList({
|
|
|
320
322
|
fetchDetails,
|
|
321
323
|
fetchReviewers,
|
|
322
324
|
defaultBranch,
|
|
325
|
+
fetchProviders,
|
|
323
326
|
openAgent,
|
|
324
327
|
started,
|
|
325
328
|
act: (item, action) => {
|
|
@@ -518,6 +521,7 @@ interface Actions {
|
|
|
518
521
|
fetchDetails: FetchDetails;
|
|
519
522
|
fetchReviewers: FetchReviewers;
|
|
520
523
|
defaultBranch: DefaultBranch;
|
|
524
|
+
fetchProviders: FetchProviders;
|
|
521
525
|
act: (item: Item, action: ActionId) => void;
|
|
522
526
|
requestReviewers: (item: Item, reviewers: string[]) => void;
|
|
523
527
|
rerun: (item: Item, runIds: number[]) => void;
|
|
@@ -1037,7 +1041,7 @@ function SessionOptions({ spec, actions, onClose }: { spec: OptionsSpec; actions
|
|
|
1037
1041
|
listProfiles(paseo),
|
|
1038
1042
|
findCheckout(paseo, actions.config, target, actions.defaultBranch),
|
|
1039
1043
|
// Without a ready provider, still show the options; starting reports the error.
|
|
1040
|
-
resolveAgentConfig(paseo, kind, actions.config).catch(() => ({ label: "No agent provider is ready" })),
|
|
1044
|
+
resolveAgentConfig(paseo, actions.fetchProviders, kind, actions.config).catch(() => ({ label: "No agent provider is ready" })),
|
|
1041
1045
|
]);
|
|
1042
1046
|
const workspaces = checkout.project ? await branchWorkspaces(paseo, checkout.project.projectId, target.headRefName) : [];
|
|
1043
1047
|
return { prompt: renderPrompt(kind, target, context, actions.config), profiles, checkout, workspaces, defaultLabel: defaults.label };
|
|
@@ -1055,7 +1059,7 @@ function SessionOptions({ spec, actions, onClose }: { spec: OptionsSpec; actions
|
|
|
1055
1059
|
setStarting(true);
|
|
1056
1060
|
try {
|
|
1057
1061
|
await spec.before?.();
|
|
1058
|
-
await actions.started(await startSession(paseo, { itemKey, kind, target, prompt: prompt ?? data.prompt, config: actions.config, checkout: data.checkout, profileId, workspaceId }));
|
|
1062
|
+
await actions.started(await startSession(paseo, { itemKey, kind, target, prompt: prompt ?? data.prompt, config: actions.config, fetchProviders: actions.fetchProviders, checkout: data.checkout, profileId, workspaceId }));
|
|
1059
1063
|
onClose();
|
|
1060
1064
|
} catch (error) {
|
|
1061
1065
|
toast.error(`Starting the session failed: ${(error as Error).message}`);
|
|
@@ -5,8 +5,7 @@ import { useState } from "react";
|
|
|
5
5
|
import { Text, View } from "react-native";
|
|
6
6
|
import * as rpc from "../shared/rpc";
|
|
7
7
|
import type { ConfigStatus, CoverageKind } from "../shared/setup";
|
|
8
|
-
import {
|
|
9
|
-
import { useHostLabel } from "./host";
|
|
8
|
+
import { VIEW_QUERY_KEY } from "./data";
|
|
10
9
|
import { Button, StylesProvider, useStyles } from "./ui";
|
|
11
10
|
|
|
12
11
|
const COVERAGE_QUERY_KEY = ["attention-span", "coverage"] as const;
|
|
@@ -16,26 +15,14 @@ const CAPTION = { marginTop: -24, marginBottom: 16 };
|
|
|
16
15
|
|
|
17
16
|
// Settings → Plugins → Attention Span: which orgs and repos the lists cover, and where Next up looks,
|
|
18
17
|
// saved to config.json [SRC-02, NXT-04].
|
|
19
|
-
export function CoverageSettings({ theme, layout
|
|
18
|
+
export function CoverageSettings({ theme, layout }: PluginSurfaceProps) {
|
|
20
19
|
return (
|
|
21
20
|
<StylesProvider theme={theme} compact={layout.compact}>
|
|
22
|
-
<
|
|
23
|
-
<HostLine host={host} />
|
|
24
|
-
<Coverage />
|
|
25
|
-
</View>
|
|
21
|
+
<Coverage />
|
|
26
22
|
</StylesProvider>
|
|
27
23
|
);
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
// Which host's config.json this edits, and its GitHub account, when there are several hosts [REACH-02].
|
|
31
|
-
function HostLine({ host }: Pick<PluginSurfaceProps, "host">) {
|
|
32
|
-
const styles = useStyles();
|
|
33
|
-
const label = useHostLabel(host);
|
|
34
|
-
const login = useAttention().data?.login;
|
|
35
|
-
if (!label) return null;
|
|
36
|
-
return <Text style={styles.muted}>{login ? `These settings are for ${label}, signed in to GitHub as @${login}.` : `These settings are for ${label}.`}</Text>;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
26
|
function Coverage() {
|
|
40
27
|
const styles = useStyles();
|
|
41
28
|
const queryClient = useQueryClient();
|
package/client/feedback.tsx
CHANGED
|
@@ -90,6 +90,7 @@ export function FeedbackAsk({
|
|
|
90
90
|
const paseo = usePaseo();
|
|
91
91
|
const toast = useToast();
|
|
92
92
|
const fetchInfo = useRpc(rpc.feedbackInfo);
|
|
93
|
+
const fetchProviders = useRpc(rpc.readyProviders);
|
|
93
94
|
const [message, setMessage] = useState("");
|
|
94
95
|
const [starting, setStarting] = useState(false);
|
|
95
96
|
|
|
@@ -98,7 +99,7 @@ export function FeedbackAsk({
|
|
|
98
99
|
try {
|
|
99
100
|
const info = await fetchInfo({});
|
|
100
101
|
const prompt = feedbackPrompt(kind, { ...screen, message, dir: info.source, version: info.version });
|
|
101
|
-
const { agent } = await resolveAgentConfig(paseo, "start", config);
|
|
102
|
+
const { agent } = await resolveAgentConfig(paseo, () => fetchProviders({}).then((result) => result.providers), "start", config);
|
|
102
103
|
const workspace = await paseo.workspaces.open({ cwd: info.cwd });
|
|
103
104
|
const created = await workspace.agents.create({
|
|
104
105
|
config: agent,
|
package/client/sessions.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { usePaseo } from "@getpaseo/plugin/client";
|
|
2
2
|
import type { AgentSummary, Target } from "../shared/attention";
|
|
3
|
+
import { chooseAgent, type ReadyProvider } from "../shared/providers";
|
|
3
4
|
import { type AttentionConfig, codeRepoFor, githubRepoOf, SessionKind } from "../shared/config";
|
|
4
5
|
|
|
5
6
|
type Paseo = ReturnType<typeof usePaseo>;
|
|
@@ -107,10 +108,13 @@ export async function listProfiles(paseo: Paseo): Promise<ProfileChoice[]> {
|
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
type AgentConfig = Parameters<Paseo["agents"]["create"]>[0]["config"];
|
|
111
|
+
// Asks the plugin's server, whose snapshot always has the entries [SES-06].
|
|
112
|
+
export type FetchProviders = () => Promise<ReadyProvider[]>;
|
|
110
113
|
|
|
111
114
|
// The profile configured for the session type, then "default", then Paseo's defaults [SES-01, SES-06].
|
|
112
115
|
export async function resolveAgentConfig(
|
|
113
116
|
paseo: Paseo,
|
|
117
|
+
fetchProviders: FetchProviders,
|
|
114
118
|
kind: SessionKind,
|
|
115
119
|
config: AttentionConfig,
|
|
116
120
|
profileId?: string,
|
|
@@ -120,32 +124,9 @@ export async function resolveAgentConfig(
|
|
|
120
124
|
const byName = (name: string | undefined) =>
|
|
121
125
|
name ? profiles.find((p) => p.id === name || p.name.toLowerCase() === name.toLowerCase()) : undefined;
|
|
122
126
|
const profile = profileId ? byName(profileId) : (byName(config.profiles[kind]) ?? byName(config.profiles.default));
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const defaultModel = (provider: string) => {
|
|
127
|
-
const entry = providers.find((candidate) => candidate.provider === provider);
|
|
128
|
-
return (entry?.models ?? []).find((model) => model.isDefault)?.id ?? entry?.models?.[0]?.id;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
if (profile) {
|
|
132
|
-
const model = profile.model ?? defaultModel(profile.provider);
|
|
133
|
-
return {
|
|
134
|
-
label: profile.name,
|
|
135
|
-
agent: {
|
|
136
|
-
provider: model ? `${profile.provider}/${model}` : profile.provider,
|
|
137
|
-
modeId: profile.modeId,
|
|
138
|
-
thinkingOptionId: profile.thinkingOptionId,
|
|
139
|
-
featureValues: profile.featureValues,
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
const fallback = providers.find((entry) => defaultModel(entry.provider));
|
|
144
|
-
if (!fallback) throw new Error("No agent provider is ready on this host.");
|
|
145
|
-
return {
|
|
146
|
-
label: `Paseo default (${fallback.label})`,
|
|
147
|
-
agent: { provider: `${fallback.provider}/${defaultModel(fallback.provider)}`, modeId: fallback.defaultModeId ?? undefined },
|
|
148
|
-
};
|
|
127
|
+
// A profile that names its model needs no provider lookup.
|
|
128
|
+
const providers = profile?.model ? [] : await fetchProviders();
|
|
129
|
+
return chooseAgent(profile, providers);
|
|
149
130
|
}
|
|
150
131
|
|
|
151
132
|
function slug(text: string): string {
|
|
@@ -162,6 +143,7 @@ export interface StartSession {
|
|
|
162
143
|
target: Target;
|
|
163
144
|
prompt: string;
|
|
164
145
|
config: AttentionConfig;
|
|
146
|
+
fetchProviders: FetchProviders;
|
|
165
147
|
checkout: Checkout;
|
|
166
148
|
profileId?: string;
|
|
167
149
|
workspaceId?: string; // an existing workspace; otherwise a new worktree
|
|
@@ -172,7 +154,7 @@ export async function startSession(paseo: Paseo, input: StartSession): Promise<s
|
|
|
172
154
|
const { target, checkout } = input;
|
|
173
155
|
const project = checkout.project;
|
|
174
156
|
if (!project) throw new Error(noProjectMessage(checkout, target));
|
|
175
|
-
const { agent: agentConfig } = await resolveAgentConfig(paseo, input.kind, input.config, input.profileId);
|
|
157
|
+
const { agent: agentConfig } = await resolveAgentConfig(paseo, input.fetchProviders, input.kind, input.config, input.profileId);
|
|
176
158
|
const title = `${target.kind === "pr" ? "PR" : "Issue"} ${target.number}: ${target.title}`.slice(0, 120);
|
|
177
159
|
|
|
178
160
|
const workspace = input.workspaceId
|
package/docs/architecture.md
CHANGED
|
@@ -25,8 +25,8 @@ flowchart LR
|
|
|
25
25
|
|
|
26
26
|
- **Paseo plugin**, installed per daemon.
|
|
27
27
|
- Client: one screen and a sidebar header item. React Native primitives only, so it works on phone and desktop [REACH-01].
|
|
28
|
-
- With more than one host in the app, each host runs its own copy, with its own `gh` login, `config.json` and `state.json`. The sidebar row shows the host's name beside the count, and settings say which host they're for and its GitHub login. The app doesn't say which other hosts have the plugin, so any second host counts [REACH-02].
|
|
29
28
|
- Server: RPC handlers for fetching and for GitHub actions.
|
|
29
|
+
- With several hosts, each runs its own copy, with its own `gh` login, `config.json` and `state.json`. Paseo shows one sidebar row for all of them and switches hosts with the picker in the screen's header; the row follows the host in view, else the one picked last.
|
|
30
30
|
- **GitHub access** goes through the host's existing `gh` login. The plugin stores no token [SEC-01].
|
|
31
31
|
- **Setup checklist** [SET-01]: when a refresh fails, the screen asks the server what setup needs (`gh api user` for whether `gh` is there and who it's signed in as, and whether `config.json` parses). If `gh` is missing or signed out, or the file is broken, a checklist takes the tabs' place. Each line says how to fix it, and Check again refreshes. It also lists what's covered, the Paseo projects with a GitHub remote, and which profile sessions will use. Other failures, like a network error, stay a red line above the tabs.
|
|
32
32
|
- **Settings screen** [SRC-02], under Settings → Plugins → Attention Span and the gear next to ⟳: orgs and repos, one per row. Each is checked with `gh api users/<org>` (it must be an organization, since searches use `org:`) or `gh api repos/<owner>/<name>` before it's saved, and GitHub's exact name is kept. Saving rewrites only `orgs` and `repos` in `config.json`, refuses a file that doesn't parse, and refreshes the lists. A Replies section has one switch, Follow threads I've commented on, which writes only `followThreads` [ATT-17].
|
|
@@ -132,7 +132,7 @@ While an item has an open session, its main action is **Open session** instead,
|
|
|
132
132
|
- **Repo to checkout** [SES-05]: match the PR's or issue's repository against the git remotes of registered Paseo projects. Repos without a project can only open GitHub.
|
|
133
133
|
- **Issues kept apart from the code** [SES-07]: an issue starts in the repo `codeRepos` maps its repo to, from that repo's default branch (one `gh repo view`). When neither has a project, Start asks which project holds the code, saves the answer to `codeRepos` and carries on. Claim waits until then, so a start that can't go anywhere doesn't leave the issue taken. The prompt and Claim keep using the issue's own repo.
|
|
134
134
|
- **Workspace**: a worktree with `checkout-pr` for PRs, or `branch-off` from the default branch for issues.
|
|
135
|
-
- **Profile**: looked up per reason in `config.json`, then materialised into `create_agent` from `list_profiles`. A missing `review` profile falls back to `default`; a missing `default` starts the agent with Paseo's defaults. Options ▾ still offers provider and model [SES-06].
|
|
135
|
+
- **Profile**: looked up per reason in `config.json`, then materialised into `create_agent` from `list_profiles`. A missing `review` profile falls back to `default`; a missing `default` starts the agent with Paseo's defaults: the first ready provider and its default model. The plugin's server reads the provider list (`providers.ready`), because the app's own snapshot can arrive compact, with no entries. Options ▾ still offers provider and model [SES-06].
|
|
136
136
|
- **Prompt**: a built-in template per session type, filled with the item's context. A template in `config.json` replaces the built-in one [SES-04]. The context is fetched when the session starts, mostly from `gh`'s JSON output: `gh pr checks` and `gh run view --log-failed` for Fix, `gh pr view`/`gh issue view` for Review and Start, one GraphQL query for unresolved threads for Address. Rebase uses the stack already in the item.
|
|
137
137
|
|
|
138
138
|
## Feedback
|
package/index.client.tsx
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import type { PluginClientContext, PluginScreenProps, PluginSidebarItemProps } from "@getpaseo/plugin/client";
|
|
2
2
|
import { SidebarRow } from "@getpaseo/plugin/client/ui";
|
|
3
|
-
import { Text
|
|
3
|
+
import { Text } from "react-native";
|
|
4
4
|
import { AttentionScreen } from "./client/attention-screen";
|
|
5
5
|
import { CoverageSettings } from "./client/coverage-settings";
|
|
6
6
|
import { useAttention } from "./client/data";
|
|
7
7
|
import { returnFromFeedback } from "./client/feedback";
|
|
8
|
-
import { useHostLabel } from "./client/host";
|
|
9
8
|
import { ICONS } from "./client/icons";
|
|
10
9
|
|
|
11
|
-
// The count, visible from anywhere in Paseo [ATT-09]
|
|
12
|
-
function SidebarItem({ theme,
|
|
10
|
+
// The count, visible from anywhere in Paseo [ATT-09].
|
|
11
|
+
function SidebarItem({ theme, currentScreen, openScreen }: PluginSidebarItemProps) {
|
|
13
12
|
const { data } = useAttention();
|
|
14
|
-
const hostLabel = useHostLabel(host);
|
|
15
13
|
const count = data?.count ?? 0;
|
|
16
|
-
const muted = { color: theme.colors.foregroundMuted, fontSize: 12 };
|
|
17
14
|
return (
|
|
18
15
|
<SidebarRow
|
|
19
16
|
icon={ICONS.logo}
|
|
@@ -21,15 +18,8 @@ function SidebarItem({ theme, host, currentScreen, openScreen }: PluginSidebarIt
|
|
|
21
18
|
active={currentScreen?.screenId === "attention"}
|
|
22
19
|
onPress={() => openScreen({ screenId: "attention" })}
|
|
23
20
|
trailing={
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
{hostLabel ? (
|
|
27
|
-
<Text style={[muted, { maxWidth: 120 }]} numberOfLines={1}>
|
|
28
|
-
{hostLabel}
|
|
29
|
-
</Text>
|
|
30
|
-
) : null}
|
|
31
|
-
{count > 0 ? <Text style={[muted, data?.feeds.live.error ? { color: theme.colors.statusDanger } : null]}>{count}</Text> : null}
|
|
32
|
-
</View>
|
|
21
|
+
count > 0 ? (
|
|
22
|
+
<Text style={{ color: data?.feeds.live.error ? theme.colors.statusDanger : theme.colors.foregroundMuted, fontSize: 12 }}>{count}</Text>
|
|
33
23
|
) : undefined
|
|
34
24
|
}
|
|
35
25
|
/>
|
package/index.server.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { FIXTURE } from "./server/gh";
|
|
|
22
22
|
import { checkCoverage, configStatus, myOrgs, setupStatus } from "./server/setup";
|
|
23
23
|
import { AttentionService, type Change } from "./server/service";
|
|
24
24
|
import type { Chip } from "./shared/attention";
|
|
25
|
+
import { readyProviders } from "./shared/providers";
|
|
25
26
|
import * as rpc from "./shared/rpc";
|
|
26
27
|
|
|
27
28
|
export default function contribute(server: PluginServerContext) {
|
|
@@ -71,6 +72,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
71
72
|
server.handle(rpc.itemDetails, ({ subject, target, checks }) => (FIXTURE ? Promise.resolve(fixtureDetails(subject, target, checks)) : itemDetails(subject, target, checks)));
|
|
72
73
|
server.handle(rpc.defaultBranch, async ({ repo }) => ({ name: FIXTURE ? "main" : await defaultBranch(repo) }));
|
|
73
74
|
server.handle(rpc.feedbackInfo, () => feedbackInfo());
|
|
75
|
+
// The server's Paseo connection expands the snapshot; the app's may not (getpaseo compact snapshots) [SES-06].
|
|
76
|
+
server.handle(rpc.readyProviders, async (_input, { paseo }) => ({ providers: readyProviders((await paseo.providers.snapshot()).entries) }));
|
|
74
77
|
server.handle(rpc.sessionContext, async ({ kind, target }) => ({ context: FIXTURE ? FIXTURE_CONTEXT : await sessionContext(kind, target) }));
|
|
75
78
|
|
|
76
79
|
return () => attention.stop();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/requirements.yaml
CHANGED
|
@@ -114,7 +114,6 @@ non_functional:
|
|
|
114
114
|
PRIV-01: may keep a local copy of the GitHub data it shows; so that Attention Span shows instantly after a restart.
|
|
115
115
|
reach:
|
|
116
116
|
REACH-01: works in Paseo on both phone and desktop; so that I can triage from anywhere.
|
|
117
|
-
REACH-02: names its host in the sidebar and in settings when Paseo knows more than one host; so that I can tell which host's list and config.json I'm looking at.
|
|
118
117
|
freshness:
|
|
119
118
|
FRESH-01: stays current without me refreshing it; so that its count can be trusted.
|
|
120
119
|
FRESH-02: shows what I just did on GitHub right away, and keeps showing it until GitHub's search catches up; so that I never refresh to see it.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// The agent providers a session can start with, and the agent config chosen from them [SES-01, SES-06].
|
|
2
|
+
|
|
3
|
+
// A provider that is ready and enabled on the host, with the model a session gets when nothing names one.
|
|
4
|
+
export interface ReadyProvider {
|
|
5
|
+
provider: string;
|
|
6
|
+
label: string;
|
|
7
|
+
defaultModel?: string;
|
|
8
|
+
defaultModeId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// The parts of Paseo's provider snapshot entry this needs.
|
|
12
|
+
interface SnapshotEntry {
|
|
13
|
+
provider: string;
|
|
14
|
+
status: string;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
label?: string;
|
|
17
|
+
models?: { id: string; isDefault?: boolean }[];
|
|
18
|
+
defaultModeId?: string | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function readyProviders(entries: SnapshotEntry[]): ReadyProvider[] {
|
|
22
|
+
return entries
|
|
23
|
+
.filter((entry) => entry.status === "ready" && entry.enabled)
|
|
24
|
+
.map((entry) => ({
|
|
25
|
+
provider: entry.provider,
|
|
26
|
+
label: entry.label ?? entry.provider,
|
|
27
|
+
defaultModel: (entry.models ?? []).find((model) => model.isDefault)?.id ?? entry.models?.[0]?.id,
|
|
28
|
+
defaultModeId: entry.defaultModeId ?? undefined,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The parts of a Paseo agent profile this needs.
|
|
33
|
+
interface Profile {
|
|
34
|
+
name: string;
|
|
35
|
+
provider: string;
|
|
36
|
+
model?: string | null;
|
|
37
|
+
modeId?: string | null;
|
|
38
|
+
thinkingOptionId?: string | null;
|
|
39
|
+
featureValues?: Record<string, unknown> | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ChosenAgent<P extends Profile> {
|
|
43
|
+
label: string;
|
|
44
|
+
agent: { provider: string; modeId?: P["modeId"]; thinkingOptionId?: P["thinkingOptionId"]; featureValues?: P["featureValues"] };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const NO_PROVIDER = "No agent provider is ready on this host.";
|
|
48
|
+
|
|
49
|
+
// The profile with its provider's default model when it names none; without a profile, the first ready provider that has a model.
|
|
50
|
+
export function chooseAgent<P extends Profile>(profile: P | undefined, providers: ReadyProvider[]): ChosenAgent<P> {
|
|
51
|
+
if (profile) {
|
|
52
|
+
const model = profile.model ?? providers.find((entry) => entry.provider === profile.provider)?.defaultModel;
|
|
53
|
+
return {
|
|
54
|
+
label: profile.name,
|
|
55
|
+
agent: {
|
|
56
|
+
provider: model ? `${profile.provider}/${model}` : profile.provider,
|
|
57
|
+
modeId: profile.modeId,
|
|
58
|
+
thinkingOptionId: profile.thinkingOptionId,
|
|
59
|
+
featureValues: profile.featureValues,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const fallback = providers.find((entry) => entry.defaultModel);
|
|
64
|
+
if (!fallback) throw new Error(NO_PROVIDER);
|
|
65
|
+
return {
|
|
66
|
+
label: `Paseo default (${fallback.label})`,
|
|
67
|
+
agent: { provider: `${fallback.provider}/${fallback.defaultModel}`, modeId: fallback.defaultModeId },
|
|
68
|
+
};
|
|
69
|
+
}
|
package/shared/rpc.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { AttentionView, ItemDetails, ReviewerChoices, Target } from "./atte
|
|
|
4
4
|
import { SessionKind } from "./config";
|
|
5
5
|
import type { ConfigStatus, CoverageCheck, SetupStatus } from "./setup";
|
|
6
6
|
import type { FeedbackInfo } from "./feedback";
|
|
7
|
+
import type { ReadyProvider } from "./providers";
|
|
7
8
|
|
|
8
9
|
// Both sides are this plugin, so the types are checked by TypeScript, not repeated as schemas.
|
|
9
10
|
const view = z.custom<AttentionView>();
|
|
@@ -73,3 +74,5 @@ export const sessionContext = defineRpc({
|
|
|
73
74
|
|
|
74
75
|
// Where a feedback session runs and the version it reports [FB-01].
|
|
75
76
|
export const feedbackInfo = defineRpc({ name: "feedback.info", input: z.object({}), output: z.custom<FeedbackInfo>() });
|
|
77
|
+
// The host's ready providers, read by the plugin's server: the app's own snapshot can arrive compact, with no entries [SES-06].
|
|
78
|
+
export const readyProviders = defineRpc({ name: "providers.ready", input: z.object({}), output: z.custom<{ providers: ReadyProvider[] }>() });
|
package/client/host.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type PluginHostProps, useHosts } from "@getpaseo/plugin/client";
|
|
2
|
-
|
|
3
|
-
// This host's name, once the app knows more than one host, so two copies of Attention Span can be told apart [REACH-02].
|
|
4
|
-
// Hosts without the plugin count too: the app can't say which hosts have it.
|
|
5
|
-
export function useHostLabel(host: PluginHostProps["host"]): string | null {
|
|
6
|
-
const hosts = useHosts();
|
|
7
|
-
return hosts.length > 1 ? host.label : null;
|
|
8
|
-
}
|