@hearsay-tools/squawk 0.18.0-dev.7300 → 0.18.0-dev.7305
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/ci-wait/tools.d.ts +4 -4
- package/dist/contract/agent-profiles.d.ts +3 -85
- package/dist/contract/index.js +9 -56
- package/dist/contract/provider-requests.d.ts +1 -6
- package/dist/contract/run-requests.d.ts +0 -1
- package/dist/core/agent-profiles.d.ts +7 -43
- package/dist/core/agent-profiles.js +15 -70
- package/dist/core/agent-profiles.js.map +1 -1
- package/dist/delegation/execution-identity.d.ts +1 -1
- package/dist/delegation/execution-identity.js +5 -30
- package/dist/delegation/execution-identity.js.map +1 -1
- package/dist/delegation/transport.d.ts +62 -62
- package/dist/home/legacy-account-paths.js +0 -4
- package/dist/home/legacy-account-paths.js.map +1 -1
- package/dist/home/migration-accounts.d.ts +0 -2
- package/dist/home/migration-accounts.js +1 -11
- package/dist/home/migration-accounts.js.map +1 -1
- package/dist/home/migration-plan.js +4 -5
- package/dist/home/migration-plan.js.map +1 -1
- package/dist/paths.d.ts +0 -6
- package/dist/paths.js +8 -8
- package/dist/paths.js.map +1 -1
- package/dist/planner.js +1 -3
- package/dist/planner.js.map +1 -1
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/open-in-targets.js +3 -7
- package/dist/server/open-in-targets.js.map +1 -1
- package/dist/server/server.d.ts +1747 -2011
- package/dist/server/server.js +22 -165
- package/dist/server/server.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +1 -13
- package/dist/workflows/continuation-admission.js +4 -6
- package/dist/workflows/continuation-admission.js.map +1 -1
- package/dist/workflows/run/session-events.d.ts +1 -2
- package/dist/workflows/run/session-events.js +2 -4
- package/dist/workflows/run/session-events.js.map +1 -1
- package/dist/workspace/agent-accounts.d.ts +2 -15
- package/dist/workspace/agent-accounts.js +63 -35
- package/dist/workspace/agent-accounts.js.map +1 -1
- package/dist/workspace/agent-profiles.d.ts +2 -36
- package/dist/workspace/agent-profiles.js +4 -72
- package/dist/workspace/agent-profiles.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{activity-motion-DUCV5L0w.js → activity-motion-YMvJpfC8.js} +2 -2
- package/web/dist/assets/{activity-route-DhR7Phxz.js → activity-route-C3nuQQR-.js} +1 -1
- package/web/dist/assets/{agent-accounts-Ck78cTaG.js → agent-accounts-C1IZE0uf.js} +1 -1
- package/web/dist/assets/attention-SAsrxB3a.js +1 -0
- package/web/dist/assets/{commit-diff-panel-DROIgIvc.js → commit-diff-panel-B78xqBBB.js} +1 -1
- package/web/dist/assets/{diff-DpxnwWWi.js → diff-CuoNLz3Q.js} +2 -2
- package/web/dist/assets/{diff-view-CT2koEmZ.js → diff-view-Dxt-xGXY.js} +1 -1
- package/web/dist/assets/{file-preview-DoN49plc.js → file-preview-D6fgR7rc.js} +1 -1
- package/web/dist/assets/{git-toolbar-BK3rzi1x.js → git-toolbar-B4gNpVK8.js} +1 -1
- package/web/dist/assets/github-D4IdDmEF.js +1 -0
- package/web/dist/assets/{global-activity-route-S7yzZmEr.js → global-activity-route-BQW6XCBZ.js} +1 -1
- package/web/dist/assets/index-CZSDjjxd.js +14 -0
- package/web/dist/assets/index-D6Jjh8b7.css +1 -0
- package/web/dist/assets/{markdown-B0anEsMd.js → markdown-CFpzsarc.js} +1 -1
- package/web/dist/assets/picker-pill-AQuDoa6t.js +15 -0
- package/web/dist/assets/{preview-pane-connected-BzekXFjg.js → preview-pane-connected-Divki4iS.js} +2 -2
- package/web/dist/assets/{project-router-BKoMKwmx.js → project-router-CuXiyyHq.js} +1 -1
- package/web/dist/assets/{project-scope-context-Cb2B_LxQ.js → project-scope-context-TjMvUo_E.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-BBSaimz3.js → prompt-template-menu-DttDghYr.js} +1 -1
- package/web/dist/assets/queries-M7QM2Z_B.js +1 -0
- package/web/dist/assets/{reference-chip-AYFrAylA.js → reference-chip-C2uR5keT.js} +1 -1
- package/web/dist/assets/{repo-git-B7ZeLEvR.js → repo-git-Dl6O3hGA.js} +1 -1
- package/web/dist/assets/{report-reader-D3ClRGaS.js → report-reader-MmUDUBB6.js} +1 -1
- package/web/dist/assets/{reports-DY-sN7ya.js → reports-D5N5f1oD.js} +1 -1
- package/web/dist/assets/run-header-CWSg_ZYo.js +2 -0
- package/web/dist/assets/{skills-CvgUI4o3.js → skills-UhbdEQES.js} +1 -1
- package/web/dist/assets/{tab-link-CekOt2NF.js → tab-link-Bz7Tn_PW.js} +1 -1
- package/web/dist/assets/{task-changes-DI7U63bx.js → task-changes-Ciq3wQdC.js} +1 -1
- package/web/dist/assets/{task-commits-BHb8bDAK.js → task-commits-BYZEw7j8.js} +1 -1
- package/web/dist/assets/{task-files-C_JvFlH3.js → task-files-zvZu7yvk.js} +1 -1
- package/web/dist/assets/task-github-item-BYzml2gD.js +1 -0
- package/web/dist/assets/{task-thread-BcgJ2CLQ.js → task-thread-DSdn2fYx.js} +7 -7
- package/web/dist/assets/{thread-state-AfNliBC6.js → thread-state-BU_1o8aR.js} +1 -1
- package/web/dist/assets/{use-desktop-tg8hhNdq.js → use-desktop-Dc0-ZSdE.js} +1 -1
- package/web/dist/assets/use-hand-to-agent-state-C8jp_mTB.js +1 -0
- package/web/dist/assets/{useInfiniteQuery-De6BP_4x.js → useInfiniteQuery-BzvShKMo.js} +1 -1
- package/web/dist/assets/useQuery-BJvp3XYr.js +1 -0
- package/web/dist/assets/{workflows-C-sOpa7G.js → workflows-BdBF5bnk.js} +2 -2
- package/web/dist/assets/ws-BQRkvdhO.js +1 -0
- package/web/dist/index.html +14 -14
- package/dist/agent-config/account-identity.d.ts +0 -28
- package/dist/agent-config/account-identity.js +0 -132
- package/dist/agent-config/account-identity.js.map +0 -1
- package/web/dist/assets/attention-DLIMAzlf.js +0 -1
- package/web/dist/assets/github-C3NKXyls.js +0 -1
- package/web/dist/assets/index-BRcS2Xvy.css +0 -1
- package/web/dist/assets/index-DgjX4EGJ.js +0 -14
- package/web/dist/assets/picker-pill-Bd3Q9PFA.js +0 -15
- package/web/dist/assets/queries-Bb9GjWMQ.js +0 -1
- package/web/dist/assets/run-header-B2aqbtt8.js +0 -2
- package/web/dist/assets/task-github-item-Da601f-w.js +0 -1
- package/web/dist/assets/use-hand-to-agent-state-CFQoeO76.js +0 -1
- package/web/dist/assets/useQuery-BsOmvrd_.js +0 -1
- package/web/dist/assets/ws-2N3miuuZ.js +0 -1
package/dist/server/server.js
CHANGED
|
@@ -12,7 +12,7 @@ import { writeMergedConfig } from './config-merge.js';
|
|
|
12
12
|
import { applyWorkspaceConfigPatch } from './workspace-config-patch.js';
|
|
13
13
|
import { retryAutomationLogReceipt } from './automation-log-retry.js';
|
|
14
14
|
import { automationCreateSchema, automationUpdateSchema, automationCheckRequestSchema, automationLogQuerySchema } from '../contract/index.js';
|
|
15
|
-
import { providerConnectSchema, createAgentProfileSchema,
|
|
15
|
+
import { providerConnectSchema, createAgentProfileSchema, updateAgentProfileSchema, selectAgentProfileSchema, providerEnabledSchema, providerRetrySchema, providerRouteParamsSchema, agentProfileRouteParamsSchema } from '../contract/index.js';
|
|
16
16
|
import { planSchema, parseWorkflowSchema } from '../contract/index.js';
|
|
17
17
|
import { uiStateBody } from '../contract/index.js';
|
|
18
18
|
import { queuedMessagePatchSchema, continueSchema, archiveSchema, openInSchema } from '../contract/index.js';
|
|
@@ -118,15 +118,14 @@ import { claimRepoGitMutation, localPullBranches, pullRepoCheckout } from './rep
|
|
|
118
118
|
import { collectChanges, collectCommitChanges, collectRunCommits, commitAll, createOrSwitchBranch, pushCurrentBranch, readWorktreePath, } from './git-changes.js';
|
|
119
119
|
import { healthConfig, loadConfig, resolveWorktreeRetention } from '../config.js';
|
|
120
120
|
import { reportWorktreeCommands } from '../worktree-setup.js';
|
|
121
|
-
import { readConfigFile,
|
|
121
|
+
import { readConfigFile, writeConfigFile } from '../agent-config/files.js';
|
|
122
122
|
import { readAgentModelDefaults } from '../agent-config/models.js';
|
|
123
123
|
import { listAgentConfig } from '../agent-config/service.js';
|
|
124
|
-
import { findConfigFile
|
|
125
|
-
import { readAccountIdentity } from '../agent-config/account-identity.js';
|
|
124
|
+
import { findConfigFile } from '../agent-config/catalog.js';
|
|
126
125
|
import { defaultWorkspaceConfig, loadWorkspaceConfig, mergeWriteWorkspaceConfig, effectiveComposerDefault, } from '../workspace/config.js';
|
|
127
126
|
import { CONTROL_CHARS_RE, DEFAULT_AGENT_ACCOUNT_ID, defaultAgentAccountStore, isAbsoluteConfigDir, loadAgentAccounts, mergeWriteAgentAccounts, } from '../workspace/agent-accounts.js';
|
|
128
|
-
import { defaultAgentProfile, listAgentProfiles,
|
|
129
|
-
import { PROFILE_CAPABLE_PROVIDERS,
|
|
127
|
+
import { defaultAgentProfile, listAgentProfiles, profileDirState, resolveStoredProfile, sameProfileDir, } from '../workspace/agent-profiles.js';
|
|
128
|
+
import { PROFILE_CAPABLE_PROVIDERS, profileEnv, supportsProfiles } from '../core/agent-profiles.js';
|
|
130
129
|
import { shellQuote, withEnvPrefix } from '../core/shell-env.js';
|
|
131
130
|
import { resumeCommand } from '../core/runner-cli.js';
|
|
132
131
|
import { allocateProjectSlug, normalizeProjectTags, probeProjectStatus, toProjectListEntry, registerProject, removeProject, shouldRegisterProject, } from '../workspace/projects.js';
|
|
@@ -135,7 +134,7 @@ import { checkoutRepo } from './checkout.js';
|
|
|
135
134
|
import { createProject, listGithubOwners } from './create-project.js';
|
|
136
135
|
import { createWorkspaceRunFeed } from './workspace-run-feed.js';
|
|
137
136
|
import { mergeWriteProjectUiState, readUiState } from '../ui-state.js';
|
|
138
|
-
import {
|
|
137
|
+
import { expandTilde } from '../paths.js';
|
|
139
138
|
import { isLoopbackHostHeader, normalizeHostname, resolveCapabilities } from './capabilities.js';
|
|
140
139
|
import { browseDirectory, isInsideBrowseRoot, isLexicallyInsideBrowseRoot, resolveBrowseRoot } from './fs-browse.js';
|
|
141
140
|
import { resolveForge, forgeWebRoot, resolveForgeRoot, GithubPrNotFoundError, GH_CHECKS_MAX, GH_REF_STATUS_MAX } from './forge/index.js';
|
|
@@ -819,9 +818,6 @@ export function createApp(deps) {
|
|
|
819
818
|
for (const account of listAgentProfiles(store, PROVIDER_IDS)) {
|
|
820
819
|
if (account.isDefault)
|
|
821
820
|
continue; // covered by `status()` above
|
|
822
|
-
// Probing it would sign in or report on another folder (#1283); its status route says why.
|
|
823
|
-
if (namedAccountUnavailable(account.provider, account.path) !== null)
|
|
824
|
-
continue;
|
|
825
821
|
await providerAuth
|
|
826
822
|
.profileStatus(account.provider, { id: account.id, configDir: account.path })
|
|
827
823
|
.catch(() => { });
|
|
@@ -891,10 +887,7 @@ export function createApp(deps) {
|
|
|
891
887
|
return { error: `this session belongs to an account that no longer exists (${profileId})` };
|
|
892
888
|
}
|
|
893
889
|
const { profile } = resolved;
|
|
894
|
-
|
|
895
|
-
return { env: {} };
|
|
896
|
-
const unavailable = namedAccountUnavailable(provider, profile.path);
|
|
897
|
-
return unavailable !== null ? { error: unavailable } : { env: profileEnv(provider, profile.path) };
|
|
890
|
+
return { env: profile.isDefault ? {} : profileEnv(provider, profile.path) };
|
|
898
891
|
};
|
|
899
892
|
/** The copy-paste fallback shown when no terminal could be opened — same account, spelled for
|
|
900
893
|
* this platform's shell. `null` when the account environment cannot be embedded safely. */
|
|
@@ -976,10 +969,6 @@ export function createApp(deps) {
|
|
|
976
969
|
if ('error' in resolved)
|
|
977
970
|
return c.json({ error: resolved.error }, 400);
|
|
978
971
|
const { profile } = resolved;
|
|
979
|
-
// A login aimed at a folder the agent would not open signs in another account (#1283).
|
|
980
|
-
const unavailable = profile.isDefault ? null : namedAccountUnavailable(provider, profile.path);
|
|
981
|
-
if (unavailable !== null)
|
|
982
|
-
return c.json({ error: unavailable }, 409);
|
|
983
972
|
const command = providerAuth.loginCommand(provider, profile.isDefault ? null : profile.path);
|
|
984
973
|
// Fail closed: a config dir that cannot be embedded safely in this platform's shell has no
|
|
985
974
|
// safe degradation. Running the bare command would sign the user into a DIFFERENT account
|
|
@@ -1040,27 +1029,6 @@ export function createApp(deps) {
|
|
|
1040
1029
|
// Writing is a LOCAL-MACHINE capability, exactly like `PUT /api/v1/agent-config/:id`: a profile
|
|
1041
1030
|
// points an agent at a directory on the host, and the listing echoes absolute paths carrying
|
|
1042
1031
|
// the username — the same disclosure `/api/v1/health` trims in hosted mode (#431).
|
|
1043
|
-
/**
|
|
1044
|
-
* This agent's own USER-scope config files, resolved inside ONE account's folder.
|
|
1045
|
-
*
|
|
1046
|
-
* Straight from the catalog — the single home of config-file vendor knowledge — with an
|
|
1047
|
-
* `AgentHomePaths` whose slot for this provider is the account's dir. That is what makes a second
|
|
1048
|
-
* login's `settings.json` the file you open rather than the default account's, and it keeps the
|
|
1049
|
-
* ids opaque and stable so the open route below never takes a path from the client.
|
|
1050
|
-
*/
|
|
1051
|
-
const accountFiles = async (profile) => {
|
|
1052
|
-
// A discovered default is already an agent dir; a named account may keep its config in a
|
|
1053
|
-
// subfolder of its folder (omp's `agent/`).
|
|
1054
|
-
const home = {
|
|
1055
|
-
...agentHomePaths(),
|
|
1056
|
-
[AGENT_HOME_SLOT[profile.provider]]: profile.isDefault ? profile.path : profileAgentDir(profile.provider, profile.path),
|
|
1057
|
-
};
|
|
1058
|
-
const defs = listConfigFiles().filter((def) => def.scope === 'user' && def.runners.includes(profile.provider));
|
|
1059
|
-
return Promise.all(defs.map(async (def) => {
|
|
1060
|
-
const path = def.resolve(bootRoot, home);
|
|
1061
|
-
return { id: def.id, label: basename(path), path, exists: (await statConfigPath(path)).exists };
|
|
1062
|
-
}));
|
|
1063
|
-
};
|
|
1064
1032
|
/** Build the wire row for one resolved profile: its dir state plus whatever auth is cached. */
|
|
1065
1033
|
const agentProfileBody = async (profile) => ({
|
|
1066
1034
|
id: profile.id,
|
|
@@ -1088,7 +1056,6 @@ export function createApp(deps) {
|
|
|
1088
1056
|
: providerAuth.peekProfileStatus(profile.provider, profile.id);
|
|
1089
1057
|
return cached ? { status: cached } : {};
|
|
1090
1058
|
})(),
|
|
1091
|
-
files: await accountFiles(profile),
|
|
1092
1059
|
});
|
|
1093
1060
|
/**
|
|
1094
1061
|
* Resolve `:id` to an account for the per-account reads below. Unlike `resolveWorkspaceProfile`
|
|
@@ -1117,7 +1084,7 @@ export function createApp(deps) {
|
|
|
1117
1084
|
return (await accountById(id)) ?? c.json({ error: `unknown account: ${id}` }, 404);
|
|
1118
1085
|
};
|
|
1119
1086
|
/** Validate a client-supplied config dir. Returns the error text, or null when it is usable. */
|
|
1120
|
-
const checkProfileDir =
|
|
1087
|
+
const checkProfileDir = (configDir) => {
|
|
1121
1088
|
if (CONTROL_CHARS_RE.test(configDir))
|
|
1122
1089
|
return 'folder must not contain control characters';
|
|
1123
1090
|
const expanded = expandTilde(configDir);
|
|
@@ -1125,20 +1092,13 @@ export function createApp(deps) {
|
|
|
1125
1092
|
// happens to be spawned in, which for a task is a throwaway worktree. Through
|
|
1126
1093
|
// `isAbsoluteConfigDir`, never a leading-`/` test — see its note: a string test refuses every
|
|
1127
1094
|
// real Windows path, and this is the only gate the Add-account dialog has.
|
|
1128
|
-
|
|
1129
|
-
return `folder must be an absolute path: ${configDir}`;
|
|
1130
|
-
// An omp account is selected by profile NAME, so only a folder in omp's profiles dir can be one.
|
|
1131
|
-
if (selectsByProfileName(provider))
|
|
1132
|
-
return ompProfileDirError(expanded);
|
|
1133
|
-
return null;
|
|
1095
|
+
return isAbsoluteConfigDir(expanded) ? null : `folder must be an absolute path: ${configDir}`;
|
|
1134
1096
|
};
|
|
1135
1097
|
/** Refuse a dir that is already some other account's (or the default's), compared through
|
|
1136
1098
|
* `realpath` — two spellings of one directory would be two accounts silently sharing one
|
|
1137
1099
|
* session store, and "which one am I logged into?" would stop having an answer. */
|
|
1138
1100
|
const conflictingProfile = async (profiles, provider, path, exceptId) => {
|
|
1139
|
-
|
|
1140
|
-
// `…/profiles/work/agent`), while a named omp account is the profile folder holding it.
|
|
1141
|
-
if (await sameProfileDir(profileAgentDir(provider, path), defaultAgentProfile(provider).path)) {
|
|
1101
|
+
if (await sameProfileDir(path, defaultAgentProfile(provider).path)) {
|
|
1142
1102
|
return 'that is already this agent\'s default folder';
|
|
1143
1103
|
}
|
|
1144
1104
|
for (const candidate of profiles) {
|
|
@@ -1179,9 +1139,6 @@ export function createApp(deps) {
|
|
|
1179
1139
|
// Which account each project uses, keyed by repo root. Served here rather than on the
|
|
1180
1140
|
// project registry because it lives in the same file as the accounts it names.
|
|
1181
1141
|
selections: editable ? store.selections : {},
|
|
1182
|
-
/** The machine-wide fallback, for repos that have chosen nothing. Withheld in hosted mode
|
|
1183
|
-
* on the same terms as the rest of this family. */
|
|
1184
|
-
defaults: editable ? store.defaults : {},
|
|
1185
1142
|
});
|
|
1186
1143
|
})
|
|
1187
1144
|
.post('/workspace/agent-profiles', jsonZodValidator(() => createAgentProfileSchema), async (c) => {
|
|
@@ -1191,7 +1148,7 @@ export function createApp(deps) {
|
|
|
1191
1148
|
if (!supportsProfiles(provider)) {
|
|
1192
1149
|
return c.json({ error: `${provider} cannot carry more than one account` }, 400);
|
|
1193
1150
|
}
|
|
1194
|
-
const dirError =
|
|
1151
|
+
const dirError = checkProfileDir(configDir);
|
|
1195
1152
|
if (dirError)
|
|
1196
1153
|
return c.json({ error: dirError }, 400);
|
|
1197
1154
|
// Read-first, exactly like `POST /projects`: the duplicate check needs `realpath`, and the
|
|
@@ -1245,7 +1202,7 @@ export function createApp(deps) {
|
|
|
1245
1202
|
const id = c.req.param('id');
|
|
1246
1203
|
const { label, configDir } = c.req.valid('json');
|
|
1247
1204
|
if (configDir !== undefined) {
|
|
1248
|
-
const dirError =
|
|
1205
|
+
const dirError = checkProfileDir(configDir);
|
|
1249
1206
|
if (dirError)
|
|
1250
1207
|
return c.json({ error: dirError }, 400);
|
|
1251
1208
|
}
|
|
@@ -1262,10 +1219,6 @@ export function createApp(deps) {
|
|
|
1262
1219
|
if (!current)
|
|
1263
1220
|
return c.json({ error: `unknown account: ${id}` }, 404);
|
|
1264
1221
|
if (configDir !== undefined) {
|
|
1265
|
-
// The provider's own folder rule needs the account, so it runs once the id is known.
|
|
1266
|
-
const dirError = await checkProfileDir(configDir, current.provider);
|
|
1267
|
-
if (dirError)
|
|
1268
|
-
return c.json({ error: dirError }, 400);
|
|
1269
1222
|
const conflict = await conflictingProfile(existing, current.provider, expandTilde(configDir), id);
|
|
1270
1223
|
if (conflict !== null)
|
|
1271
1224
|
return c.json({ error: conflict }, 409);
|
|
@@ -1325,12 +1278,6 @@ export function createApp(deps) {
|
|
|
1325
1278
|
const row = all.providers.find((candidate) => candidate.provider === account.provider);
|
|
1326
1279
|
return c.json({ status: row ?? { provider: account.provider, status: 'unknown' } });
|
|
1327
1280
|
}
|
|
1328
|
-
// A probe of an account the agent would not open reports on another folder (#1283), so the
|
|
1329
|
-
// row says why instead, without a spawn.
|
|
1330
|
-
const unavailable = namedAccountUnavailable(account.provider, account.path);
|
|
1331
|
-
if (unavailable !== null) {
|
|
1332
|
-
return c.json({ status: { provider: account.provider, status: 'unknown', hint: unavailable, profileId: account.id } });
|
|
1333
|
-
}
|
|
1334
1281
|
// "Check again" re-probes THIS account only — the other accounts' warm answers are not
|
|
1335
1282
|
// invalidated by asking about this one.
|
|
1336
1283
|
if (refresh)
|
|
@@ -1341,69 +1288,6 @@ export function createApp(deps) {
|
|
|
1341
1288
|
configDir: account.path,
|
|
1342
1289
|
}),
|
|
1343
1290
|
});
|
|
1344
|
-
})
|
|
1345
|
-
/**
|
|
1346
|
-
* Local-only account details, fetched separately on request. Keep identity out of normal
|
|
1347
|
-
* listings, logs and run persistence.
|
|
1348
|
-
*/
|
|
1349
|
-
.get('/workspace/agent-profiles/:id/details', paramZodValidator(agentProfileRouteParamsSchema), async (c) => {
|
|
1350
|
-
const account = await localAccount(c);
|
|
1351
|
-
if (account instanceof Response)
|
|
1352
|
-
return account;
|
|
1353
|
-
return c.json(await readAccountIdentity(account.provider, account.path));
|
|
1354
|
-
})
|
|
1355
|
-
/**
|
|
1356
|
-
* Open one of this account's own config files — or its folder — in a local app.
|
|
1357
|
-
*
|
|
1358
|
-
* `file` is a catalog ID from the account's own `files`, never a path: the client cannot name a
|
|
1359
|
-
* location, so there is no traversal surface here at all (the same rule
|
|
1360
|
-
* `/api/v1/agent-config/:id` follows). `folder` is the one extra keyword, and it resolves to
|
|
1361
|
-
* the account's dir rather than anything the caller spelled.
|
|
1362
|
-
*/
|
|
1363
|
-
.post('/workspace/agent-profiles/:id/open', paramZodValidator(agentProfileRouteParamsSchema), jsonZodValidator(() => openAgentAccountFileSchema), async (c) => {
|
|
1364
|
-
const account = await localAccount(c);
|
|
1365
|
-
if (account instanceof Response)
|
|
1366
|
-
return account;
|
|
1367
|
-
const { file, target } = c.req.valid('json');
|
|
1368
|
-
let path;
|
|
1369
|
-
if (file === 'folder') {
|
|
1370
|
-
path = account.path;
|
|
1371
|
-
}
|
|
1372
|
-
else {
|
|
1373
|
-
const match = (await accountFiles(account)).find((f) => f.id === file);
|
|
1374
|
-
if (!match)
|
|
1375
|
-
return c.json({ error: `unknown file: ${file}` }, 404);
|
|
1376
|
-
path = match.path;
|
|
1377
|
-
}
|
|
1378
|
-
// A file the agent has not written yet has nothing to open; say so rather than hand the OS
|
|
1379
|
-
// a missing path and report success.
|
|
1380
|
-
if (!(await statConfigPath(path)).exists && file !== 'folder') {
|
|
1381
|
-
return c.json({ error: `this account has no ${basename(path)} yet` }, 409);
|
|
1382
|
-
}
|
|
1383
|
-
// `target` names a detected app; absent means the OS default handler. Either way the PATH
|
|
1384
|
-
// came from the catalog, so an editor is only ever pointed inside this account's folder.
|
|
1385
|
-
//
|
|
1386
|
-
// Which targets APPLY is checked here rather than left to the UI, because two of them are
|
|
1387
|
-
// actively wrong rather than merely useless: `terminal` runs `cd <path>`, which fails on a
|
|
1388
|
-
// file, and a `cli:<runner>` handoff would start an agent session inside the config folder.
|
|
1389
|
-
// A route is a surface of its own; it refuses what it cannot do correctly.
|
|
1390
|
-
if (target !== undefined) {
|
|
1391
|
-
if (agentCliRunner(target) !== null) {
|
|
1392
|
-
return c.json({ error: 'agent CLIs open a task worktree, not a config folder' }, 400);
|
|
1393
|
-
}
|
|
1394
|
-
if (target === 'terminal' && file !== 'folder') {
|
|
1395
|
-
return c.json({ error: 'a terminal opens a folder, not a file' }, 400);
|
|
1396
|
-
}
|
|
1397
|
-
if (!detectOpenTargets().some((candidate) => candidate.id === target)) {
|
|
1398
|
-
return c.json({ error: `no such app on this machine: ${target}` }, 400);
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
const opened = target === undefined
|
|
1402
|
-
? await openFile(path)
|
|
1403
|
-
: await openApp(target, path);
|
|
1404
|
-
if (!opened)
|
|
1405
|
-
return c.json({ error: `could not open ${basename(path)}`, path }, 409);
|
|
1406
|
-
return c.json({ opened: true, path });
|
|
1407
1291
|
})
|
|
1408
1292
|
// Which account a PROJECT uses. On the accounts family rather than `PATCH /api/v1/projects`
|
|
1409
1293
|
// because the selection is stored beside the accounts it names — one file, one atomic write,
|
|
@@ -1412,19 +1296,13 @@ export function createApp(deps) {
|
|
|
1412
1296
|
if (!capabilities().localHandoff)
|
|
1413
1297
|
return c.json(hostedProfileRefusal, 409);
|
|
1414
1298
|
const { projectId, provider, profileId } = c.req.valid('json');
|
|
1415
|
-
|
|
1416
|
-
//
|
|
1417
|
-
//
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
// cross-reference into config.json. An unknown project is a 404 rather than an orphan
|
|
1423
|
-
// entry nobody will ever read.
|
|
1424
|
-
root = await projectRootFor(resolvedId);
|
|
1425
|
-
if (root === null)
|
|
1426
|
-
return c.json({ error: `unknown project: ${projectId}` }, 404);
|
|
1427
|
-
}
|
|
1299
|
+
const resolvedId = await workspaceProjects.canonicalProjectId(projectId);
|
|
1300
|
+
// Keyed by repo ROOT, so the selection survives the registry being rebuilt and needs no
|
|
1301
|
+
// cross-reference into config.json. An unknown project is a 404 rather than an orphan
|
|
1302
|
+
// entry nobody will ever read.
|
|
1303
|
+
const root = await projectRootFor(resolvedId);
|
|
1304
|
+
if (root === null)
|
|
1305
|
+
return c.json({ error: `unknown project: ${projectId}` }, 404);
|
|
1428
1306
|
// A user naming an account that does not exist gets told so — the opposite of how RUN
|
|
1429
1307
|
// resolution treats a dangling stored id, and deliberately: a run has no better answer
|
|
1430
1308
|
// than the default, a person does.
|
|
@@ -1436,25 +1314,14 @@ export function createApp(deps) {
|
|
|
1436
1314
|
let store;
|
|
1437
1315
|
try {
|
|
1438
1316
|
store = await mergeWriteAgentAccounts((current) => {
|
|
1439
|
-
|
|
1440
|
-
// selection, so it clears the same way rather than growing its own spelling.
|
|
1441
|
-
const selection = root === null ? current.defaults : current.selections[root] ?? {};
|
|
1317
|
+
const selection = current.selections[root] ?? {};
|
|
1442
1318
|
// `null` and the reserved `default` both mean "back to the discovered account", which
|
|
1443
1319
|
// is stored as ABSENCE — the default id is never written to the file.
|
|
1444
1320
|
if (profileId === null || profileId === DEFAULT_AGENT_ACCOUNT_ID)
|
|
1445
1321
|
delete selection[provider];
|
|
1446
1322
|
else
|
|
1447
1323
|
selection[provider] = profileId;
|
|
1448
|
-
|
|
1449
|
-
// that asymmetry is the schema's, not an oversight: `defaults` is one FIXED field with
|
|
1450
|
-
// `.default(() => ({}))`, so `mergeWriteAgentAccounts` re-materializes it on the next
|
|
1451
|
-
// write no matter what this one omits (verified). `selections` is a growing MAP, where
|
|
1452
|
-
// an emptied entry is a row per repo ever touched that says nothing. The rule stated
|
|
1453
|
-
// for `agentDefaults.models` — "absence is the same answer" — applies there because
|
|
1454
|
-
// that key is `.optional()`, so deleting it actually sticks.
|
|
1455
|
-
if (root === null)
|
|
1456
|
-
current.defaults = selection;
|
|
1457
|
-
else if (Object.keys(selection).length === 0)
|
|
1324
|
+
if (Object.keys(selection).length === 0)
|
|
1458
1325
|
delete current.selections[root];
|
|
1459
1326
|
else
|
|
1460
1327
|
current.selections[root] = selection;
|
|
@@ -1463,7 +1330,7 @@ export function createApp(deps) {
|
|
|
1463
1330
|
catch (err) {
|
|
1464
1331
|
return c.json({ error: err instanceof Error ? err.message : String(err) }, 500);
|
|
1465
1332
|
}
|
|
1466
|
-
return c.json({ selections: store.selections
|
|
1333
|
+
return c.json({ selections: store.selections });
|
|
1467
1334
|
})
|
|
1468
1335
|
.delete('/workspace/agent-profiles/:id', paramZodValidator(agentProfileRouteParamsSchema), async (c) => {
|
|
1469
1336
|
if (!capabilities().localHandoff)
|
|
@@ -2978,15 +2845,6 @@ export function createApp(deps) {
|
|
|
2978
2845
|
const blocked = await providerActionError(required);
|
|
2979
2846
|
if (blocked)
|
|
2980
2847
|
return c.json({ error: blocked }, 409);
|
|
2981
|
-
// The follow-up pill names an account the user just picked, so an id that has been deleted
|
|
2982
|
-
// since the thread loaded is answered honestly — the same asymmetry `POST /runs` keeps: a
|
|
2983
|
-
// USER can act on "unknown account", and reopening the session on another login silently
|
|
2984
|
-
// would cross the very billing boundary accounts exist to draw.
|
|
2985
|
-
if (parsed.data.agentProfile !== undefined) {
|
|
2986
|
-
const account = await resolveWorkspaceProfile(provider, parsed.data.agentProfile);
|
|
2987
|
-
if ('error' in account)
|
|
2988
|
-
return c.json({ error: account.error }, 400);
|
|
2989
|
-
}
|
|
2990
2848
|
const result = manager.continueRun(id, {
|
|
2991
2849
|
text: parsed.data.text,
|
|
2992
2850
|
images: parsed.data.images?.map(toPastedContent),
|
|
@@ -2994,7 +2852,6 @@ export function createApp(deps) {
|
|
|
2994
2852
|
...(untouched ? { originalRunner: originalProvider } : {}),
|
|
2995
2853
|
model: parsed.data.model,
|
|
2996
2854
|
effort: parsed.data.effort,
|
|
2997
|
-
agentProfile: parsed.data.agentProfile,
|
|
2998
2855
|
});
|
|
2999
2856
|
if (!result.ok)
|
|
3000
2857
|
return c.json({ error: result.error }, 409);
|