-
Notifications
You must be signed in to change notification settings - Fork 60
fix(cli): stop silently ignoring fleet enrollments behind a project pin #1439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fe20d6e
d40a3f0
ccff796
9ab6428
f8c6448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| import { registerMessagingTools } from './mcp/messaging-tools.js'; | ||
| import { identityOverrideInputShape, messageResult } from './mcp/tool-shapes.js'; | ||
| import { | ||
| describeClearedEnrollment, | ||
| persistWorkspaceSession, | ||
| resolveWorkspaceSessionKey, | ||
| validateWorkspaceSessionName, | ||
|
|
@@ -275,7 +276,7 @@ | |
| }); | ||
| } catch (err) { | ||
| if ((err as { name?: string }).name === 'AbortError') { | ||
| throw new Error(`Agent Relay result submission timed out after ${timeoutMs}ms`); | ||
| } | ||
| throw err; | ||
| } finally { | ||
|
|
@@ -328,7 +329,7 @@ | |
| return { agentName, agentToken }; | ||
| } | ||
|
|
||
| export async function registerAgentWithRebind({ | ||
| session, | ||
| setSession, | ||
| getRelay, | ||
|
|
@@ -409,7 +410,7 @@ | |
| title: 'Create Workspace', | ||
| description: | ||
| 'Explicitly start a new Agent Relay workspace session and persist it for this project. ' + | ||
| 'Returns the new workspace key and its resolved name. A `warning` field is present only when the workspace was created but its session could not be saved to disk, meaning the key must be kept and re-supplied to reconnect.', | ||
| "Returns the new workspace key and its resolved name. A `warning` field appears in two cases, and its text says which: the workspace was created but its session could not be saved to disk, meaning the key must be kept and re-supplied to reconnect; or the session was saved and doing so dropped this project's enrolled Cloud fleet node, because the new workspace is not the one that node belongs to.", | ||
| inputSchema: { | ||
| name: z.string().describe('Human-readable workspace name'), | ||
| }, | ||
|
|
@@ -438,7 +439,12 @@ | |
| }); | ||
| let persistenceWarning: string | undefined; | ||
| try { | ||
| persistWorkspaceSession({ name: workspaceName, workspaceKey }); | ||
| // A new workspace key never matches an existing pin, so this can drop | ||
| // the project's enrolled fleet node. Report it rather than letting the | ||
| // next `node up` be the first thing that mentions it. | ||
| persistenceWarning = describeClearedEnrollment( | ||
| persistWorkspaceSession({ name: workspaceName, workspaceKey }) | ||
| ); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| persistenceWarning = | ||
|
|
@@ -459,7 +465,7 @@ | |
| title: 'Set Workspace Key', | ||
| description: | ||
| 'Join this MCP session to an existing Agent Relay workspace using a shared workspace key. ' + | ||
| 'Returns a confirmation message stating whether the key was persisted for this project, and whether "register_agent" must be called to claim an identity in the newly joined workspace.', | ||
| 'Returns a confirmation message stating whether the key was persisted for this project, and whether "register_agent" must be called to claim an identity in the newly joined workspace. The message also reports when joining dropped this project\'s enrolled Cloud fleet node, which happens when the key names a workspace that node does not belong to.', | ||
| inputSchema: { | ||
| workspace_key: z.string().optional().describe('Workspace key starting with "rk_live_"'), | ||
| api_key: z.string().optional().describe('Deprecated alias for workspace_key'), | ||
|
|
@@ -495,7 +501,9 @@ | |
| } | ||
| let persistenceWarning: string | undefined; | ||
| try { | ||
| persistWorkspaceSession({ workspaceKey: key }); | ||
| // Joining a different workspace drops this project's enrolled fleet | ||
| // node; surface that here instead of at the next `node up`. | ||
| persistenceWarning = describeClearedEnrollment(persistWorkspaceSession({ workspaceKey: key })); | ||
|
Comment on lines
+504
to
+506
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Keep cleared enrollment separate from persistence failure. A cleared enrollment means
Proposed fix+ let persistenceFailed = false;
let persistenceWarning: string | undefined;
try {
persistenceWarning = describeClearedEnrollment(persistWorkspaceSession({ workspaceKey: key }));
} catch (error) {
+ persistenceFailed = true;
// existing error message assignment
}
- const message = persistenceWarning ? `${activeMessage} ${persistenceWarning}` : persistedMessage;
+ const message = persistenceWarning
+ ? `${persistenceFailed ? activeMessage : persistedMessage} ${persistenceWarning}`
+ : persistedMessage;Based on PR objectives: MCP tools must report cleared enrollment while preserving their output contract. 📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| } catch (error) { | ||
| const persistenceError = error instanceof Error ? error.message : String(error); | ||
| persistenceWarning = | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.