Skip to content

refactor(runtime): source the VFS transport from @relayfile/adapter-core - #179

Merged
khaliqgant merged 2 commits into
mainfrom
feat/runtime-clients-from-adapter-core
Jun 2, 2026
Merged

khaliqgant merged 2 commits into
mainfrom
feat/runtime-clients-from-adapter-core

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

User description

Completes the move of integration handling out of workforce (started in relayfile-adapters#141, now published as @relayfile/adapter-core@0.3.29 + @relayfile/relay-helpers@0.3.29).

What

The VFS draft-write transport (writeJsonFile/readJsonFile/listJsonFiles/draftFile/resolveMountRoot/…) is the generic Relayfile write protocol — not workforce-specific. It now lives in @relayfile/adapter-core/vfs-client, and @agentworkforce/runtime/clients re-exports it, so there's a single source of truth and no duplicated transport.

  • Deleted packages/runtime/src/clients/request.ts (the local copy).
  • clients/index.ts re-exports the transport + RelayfileWritebackError from @relayfile/adapter-core/vfs-client.
  • errors.ts keeps WorkforceIntegrationError as an alias of the relocated RelayfileWritebackError (same class, not a subclass) so existing handlers that catch (e) { if (e instanceof WorkforceIntegrationError) … } still match what the transport throws.
  • Added @relayfile/adapter-core@^0.3.29 as a direct runtime dep (it carries /vfs-client; persona-kit only pulled /triggers + /scope-keys).

Back-compat

The public surface of @agentworkforce/runtime and /clients is unchanged (same exports, plus the new RelayfileWritebackError name). Verified at runtime:

  • RelayfileWritebackError === WorkforceIntegrationError (same class)
  • a transport error is instanceof WorkforceIntegrationError with the { provider, operation, retryable } shape intact

The merged agents that import @agentworkforce/runtime/clients need no changes. Plus the transport picks up the two review fixes made during relocation (draft-vs-receipt comparison, ..-prefix path check).

Test

runtime 57/57, typecheck clean. deploy / mcp-workforce / cli typecheck clean.

Result

Workforce now owns zero integration-specific logic: the path catalog, the write transport, and the ergonomic per-provider clients all live in the relayfile layer. Follow-up (separate): migrate the agents to @relayfile/relay-helpers.

🤖 Generated with Claude Code


CodeAnt-AI Description

Move runtime client transport to the shared Relayfile package without changing handler usage

What Changed

  • Runtime clients now use the shared Relayfile draft-write transport instead of a local copy
  • Existing imports from @agentworkforce/runtime and @agentworkforce/runtime/clients still work, with the new RelayfileWritebackError name also available
  • WorkforceIntegrationError remains the same error shape and still matches transport failures in existing error handling
  • The runtime package now depends directly on the Relayfile adapter package that provides this shared transport

Impact

✅ Same client behavior for existing handlers
✅ Clearer integration writeback errors
✅ Fewer transport mismatches between runtime and Relayfile

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Completes moving integration handling out of workforce. The VFS draft-write
transport (writeJsonFile/readJsonFile/draftFile/resolveMountRoot/…) now lives in
@relayfile/adapter-core/vfs-client (the generic Relayfile write protocol, not
anything workforce-specific). runtime/clients re-exports it so the single
source of truth is the relayfile layer and there's no duplicated transport.

- Deleted packages/runtime/src/clients/request.ts (the local copy).
- clients/index.ts re-exports the transport + RelayfileWritebackError from
  @relayfile/adapter-core/vfs-client.
- errors.ts keeps `WorkforceIntegrationError` as an ALIAS of the relocated
  `RelayfileWritebackError` (same class, not a subclass) so handlers that
  `catch (e) { e instanceof WorkforceIntegrationError }` still match what the
  transport throws. Verified: alias identity holds + instanceof works.
- Added @relayfile/adapter-core@^0.3.29 as a direct runtime dep (it has the
  /vfs-client subpath; persona-kit only used /triggers + /scope-keys).

Existing agents importing @agentworkforce/runtime/clients are unchanged. The
ergonomic per-provider clients live in @relayfile/relay-helpers. runtime 57/57;
deploy/mcp-workforce/cli typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codeant-ai

codeant-ai Bot commented Jun 2, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@khaliqgant, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 42 minutes and 35 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4fd5d8d7-042a-4c9e-a845-51d6ca111993

📥 Commits

Reviewing files that changed from the base of the PR and between 7628346 and b87ed6a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • packages/runtime/package.json
  • packages/runtime/src/clients/index.ts
  • packages/runtime/src/clients/request.ts
  • packages/runtime/src/errors.ts
  • packages/runtime/src/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/runtime-clients-from-adapter-core

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Jun 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the runtime by offloading the VFS-backed transport layer and its associated error classes to the external @relayfile/adapter-core package, while maintaining backward compatibility through re-exports and class aliasing. The review feedback suggests declaring @relayfile/sdk as a peer dependency to avoid installation warnings, and recommends exporting the error option types (RelayfileWritebackErrorOptions and WorkforceIntegrationErrorOptions) across the public API entry points to ensure completeness.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

"@agent-assistant/proactive": "^0.4.32",
"@agentworkforce/persona-kit": "workspace:*"
"@agentworkforce/persona-kit": "workspace:*",
"@relayfile/adapter-core": "^0.3.29"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since @relayfile/adapter-core has a peer dependency on @relayfile/sdk (>=0.6.0 <1), consumers of @agentworkforce/runtime may encounter peer dependency resolution warnings during installation if @relayfile/sdk is not explicitly declared.

Consider adding @relayfile/sdk to the peerDependencies of @agentworkforce/runtime to ensure clean installations:

  "peerDependencies": {
    "@relayfile/sdk": ">=0.6.0 <1"
  }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declining this one: @relayfile/adapter-core/vfs-client (the only subpath the runtime imports) doesn't import @relayfile/sdk at all, @relayfile/sdk isn't resolvable in the workforce tree, and the sibling consumer @agentworkforce/persona-kit (which also depends on adapter-core) doesn't declare it either — yet everything builds and tests green. Adding it as a peer would impose an unused, uninstalled dependency on every runtime consumer and diverge from the repo's existing convention. The unmet peer is adapter-core's to resolve (ideally peerDependenciesMeta.optional there) rather than something each consumer re-declares.

readTextFile,
resolveMountRoot,
writeJsonFile,
RelayfileWritebackError,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure the public API is complete and fully backward-compatible, consider exporting RelayfileWritebackErrorOptions from @relayfile/adapter-core/vfs-client as well. This allows consumers to properly type-annotate error options when working with RelayfileWritebackError.

Suggested change
RelayfileWritebackError,
RelayfileWritebackError,
type RelayfileWritebackErrorOptions,

Comment thread packages/runtime/src/clients/index.ts Outdated
} from '@relayfile/adapter-core/vfs-client';

export { WorkforceIntegrationError, SandboxNotAvailableError } from '../errors.js'; No newline at end of file
export { WorkforceIntegrationError, SandboxNotAvailableError } from '../errors.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider exporting WorkforceIntegrationErrorOptions from ../errors.js to maintain completeness of the public API for consumers who need to type-annotate or handle error options.

Suggested change
export { WorkforceIntegrationError, SandboxNotAvailableError } from '../errors.js';
export {
WorkforceIntegrationError,
type WorkforceIntegrationErrorOptions,
SandboxNotAvailableError
} from '../errors.js';

type IntegrationClientOptions,
type WritebackReceipt,
type WritebackResult,
RelayfileWritebackError,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To expose the error option types in the main entry point of the package, consider re-exporting RelayfileWritebackErrorOptions and WorkforceIntegrationErrorOptions here as well.

Suggested change
RelayfileWritebackError,
RelayfileWritebackError,
type RelayfileWritebackErrorOptions,
type WorkforceIntegrationErrorOptions,

@codeant-ai

codeant-ai Bot commented Jun 2, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

gemini review: export RelayfileWritebackErrorOptions +
WorkforceIntegrationErrorOptions from /clients and the main entry so consumers
can type-annotate error options. (Declined the suggested @relayfile/sdk peer
dep — vfs-client doesn't import sdk, persona-kit doesn't declare it, and it
isn't in the tree; adding it would impose an unused dep.)

runtime 57/57, typecheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/runtime/src/errors.ts">

<violation number="1" location="packages/runtime/src/errors.ts:12">
P2: Aliasing `WorkforceIntegrationError` to `RelayfileWritebackError` changes the emitted error `name`, which can break existing `err.name`-based handlers.</violation>
</file>

<file name="packages/runtime/package.json">

<violation number="1" location="packages/runtime/package.json:54">
P2: Adding `@relayfile/adapter-core` introduces a transitive peer requirement on `@relayfile/sdk`; declare that peer at this package boundary so consumers get an explicit install contract and avoid unmet-peer warnings.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

}
export {
RelayfileWritebackError,
RelayfileWritebackError as WorkforceIntegrationError,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Aliasing WorkforceIntegrationError to RelayfileWritebackError changes the emitted error name, which can break existing err.name-based handlers.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/runtime/src/errors.ts, line 12:

<comment>Aliasing `WorkforceIntegrationError` to `RelayfileWritebackError` changes the emitted error `name`, which can break existing `err.name`-based handlers.</comment>

<file context>
@@ -1,44 +1,18 @@
-}
+export {
+  RelayfileWritebackError,
+  RelayfileWritebackError as WorkforceIntegrationError,
+  type RelayfileWritebackErrorOptions,
+  type RelayfileWritebackErrorOptions as WorkforceIntegrationErrorOptions
</file context>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional, declining. The alias keeps WorkforceIntegrationError as the same class as RelayfileWritebackError, which is what preserves the critical back-compat: a transport error stays instanceof WorkforceIntegrationError (a subclass would break that, since the relocated transport throws the base). The trade-off is err.name now reads RelayfileWritebackError — which is accurate, and nothing in workforce or the agents keys on that string (grepped; all use instanceof). The provider/operation/retryable/message fields are unchanged.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I've saved this as a new learning to improve future reviews.

Comment on lines +54 to 56
"@relayfile/adapter-core": "^0.3.29"
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Adding @relayfile/adapter-core introduces a transitive peer requirement on @relayfile/sdk; declare that peer at this package boundary so consumers get an explicit install contract and avoid unmet-peer warnings.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/runtime/package.json, line 54:

<comment>Adding `@relayfile/adapter-core` introduces a transitive peer requirement on `@relayfile/sdk`; declare that peer at this package boundary so consumers get an explicit install contract and avoid unmet-peer warnings.</comment>

<file context>
@@ -50,6 +50,7 @@
     "@agent-assistant/proactive": "^0.4.32",
-    "@agentworkforce/persona-kit": "workspace:*"
+    "@agentworkforce/persona-kit": "workspace:*",
+    "@relayfile/adapter-core": "^0.3.29"
   }
 }
</file context>
Suggested change
"@relayfile/adapter-core": "^0.3.29"
}
}
"@relayfile/adapter-core": "^0.3.29"
},
"peerDependencies": {
"@relayfile/sdk": ">=0.6.0 <1"
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the gemini thread above — declining. @relayfile/adapter-core/vfs-client (the only subpath the runtime imports) does not import @relayfile/sdk, the sibling consumer @agentworkforce/persona-kit (which also deps adapter-core) doesn't declare it, and @relayfile/sdk isn't even resolvable in the tree — yet build/tests are green. Declaring it here imposes an unused, uninstalled dependency on every runtime consumer. The unmet peer is adapter-core's to fix (ideally peerDependenciesMeta.optional).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I've saved this as a new learning to improve future reviews.

@khaliqgant
khaliqgant merged commit 4284451 into main Jun 2, 2026
3 checks passed
@khaliqgant
khaliqgant deleted the feat/runtime-clients-from-adapter-core branch June 2, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant