diff --git a/packages/persona-kit/package.json b/packages/persona-kit/package.json index 511fcba..9a8eeea 100644 --- a/packages/persona-kit/package.json +++ b/packages/persona-kit/package.json @@ -41,7 +41,7 @@ "lint": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@relayfile/adapter-core": "^0.3.59", + "@relayfile/adapter-core": "^0.3.60", "@relayfile/local-mount": "^0.7.24" }, "devDependencies": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index fefee0d..94c3d35 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -56,7 +56,7 @@ "@agent-assistant/proactive": "^0.4.32", "@agent-relay/events": "^6.3.3", "@agentworkforce/persona-kit": "workspace:*", - "@relayfile/adapter-core": "^0.3.59", + "@relayfile/adapter-core": "^0.3.60", "agent-trajectories": "^0.5.3" } } diff --git a/packages/runtime/src/clients/index.ts b/packages/runtime/src/clients/index.ts index ab54058..1fdc921 100644 --- a/packages/runtime/src/clients/index.ts +++ b/packages/runtime/src/clients/index.ts @@ -1,9 +1,8 @@ -import * as adapterVfsClient from '@relayfile/adapter-core/vfs-client'; import { writeJsonFile as coreWriteJsonFile, - RelayfileWritebackError, + normalizeWritebackStatus, + WritebackError, type IntegrationClientOptions, - type WritebackReceipt, type WritebackResult } from '@relayfile/adapter-core/vfs-client'; @@ -25,8 +24,12 @@ export { readTextFile, resolveMountRoot, RelayfileWritebackError, + WritebackError, + normalizeWritebackStatus, type RelayfileWritebackErrorOptions, type IntegrationClientOptions, + type NormalizedWritebackState, + type NormalizedWritebackStatus, type WritebackReceipt, type WritebackResult } from '@relayfile/adapter-core/vfs-client'; @@ -37,101 +40,6 @@ export { SandboxNotAvailableError } from '../errors.js'; -export type NormalizedWritebackState = - | 'succeeded' - | 'no_receipt' - | 'validation_failed' - | 'readonly_rejected' - | 'adapter_error' - | 'ok'; - -export interface NormalizedWritebackStatus { - state: NormalizedWritebackState; - path: string; - op?: 'create' | 'patch' | 'delete'; - id?: string; - error?: string; - field?: string; - receipt?: WritebackReceipt; - timestamp?: string; - entry?: unknown; -} - -type AdapterVfsClientExtensions = { - normalizeWritebackStatus?: ( - result?: WritebackResult, - entry?: unknown - ) => NormalizedWritebackStatus; - WritebackError?: new (normalized: NormalizedWritebackStatus) => RelayfileWritebackError & - NormalizedWritebackStatus; -}; - -class FallbackWritebackError extends RelayfileWritebackError { - readonly state: NormalizedWritebackState; - readonly path: string; - readonly op?: 'create' | 'patch' | 'delete'; - readonly id?: string; - readonly receipt?: WritebackReceipt; - readonly error?: string; - readonly field?: string; - readonly timestamp?: string; - - constructor(normalized: NormalizedWritebackStatus) { - super({ - provider: 'writeback', - operation: normalized.state, - cause: normalized.error ? new Error(normalized.error) : undefined, - retryable: false - }); - this.name = 'WritebackError'; - this.message = `writeback ${normalized.state} ${normalized.path}${ - normalized.error ? `: ${normalized.error}` : '' - }`; - this.state = normalized.state; - this.path = normalized.path; - this.op = normalized.op; - this.id = normalized.id; - this.receipt = normalized.receipt; - this.error = normalized.error; - this.field = normalized.field; - this.timestamp = normalized.timestamp; - } -} - -const adapterExtensions = adapterVfsClient as AdapterVfsClientExtensions; - -export const WritebackError = adapterExtensions.WritebackError ?? FallbackWritebackError; - -export function normalizeWritebackStatus( - result?: WritebackResult, - entry?: unknown -): NormalizedWritebackStatus { - const normalize = adapterExtensions.normalizeWritebackStatus; - if (normalize) return normalize(result, entry); - - if (!result?.receipt) { - return { - state: 'no_receipt', - path: result?.path ?? '', - error: 'writeback produced no receipt' - }; - } - - const receipt = result.receipt; - const id = - receipt.id !== undefined - ? String(receipt.id) - : receipt.created !== undefined - ? String(receipt.created) - : undefined; - return { - state: 'succeeded', - path: result.path, - ...(id ? { id } : {}), - receipt - }; -} - export async function writeJsonFile( client: IntegrationClientOptions, provider: string, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2dd0b47..f371df5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -109,8 +109,8 @@ importers: packages/persona-kit: dependencies: '@relayfile/adapter-core': - specifier: ^0.3.59 - version: 0.3.59(@relayfile/sdk@0.7.40) + specifier: ^0.3.60 + version: 0.3.60(@relayfile/sdk@0.7.40) '@relayfile/local-mount': specifier: ^0.7.24 version: 0.7.24 @@ -143,8 +143,8 @@ importers: specifier: workspace:* version: link:../persona-kit '@relayfile/adapter-core': - specifier: ^0.3.59 - version: 0.3.59(@relayfile/sdk@0.7.40) + specifier: ^0.3.60 + version: 0.3.60(@relayfile/sdk@0.7.40) agent-trajectories: specifier: ^0.5.3 version: 0.5.3 @@ -954,8 +954,8 @@ packages: resolution: {integrity: sha512-C5eVSepGrlQY5b1yg+LfROLYhDW/w1WFVsuitRzvbXMr+qpFYFHLoMNxa9R0Q6ZiP02r6EXSazii2VNo2LZ0Vg==} engines: {node: '>=22'} - '@relayfile/adapter-core@0.3.59': - resolution: {integrity: sha512-lJG/trIkLr79+R6JVlWSf+DoF8fyAvl7x4KmgeGcaaTKK0PkQgjseDHm3NWsKan6WlfVjiw91jJrwZBIvJ9kJw==} + '@relayfile/adapter-core@0.3.60': + resolution: {integrity: sha512-Q7qSvgTX+0r+OUSfEwVE8VoVQeweR3yVm4K9Z9mQkEXian0u0BDHEmWle3PQkDyTYovVaMglg9e5Y0w7hF3Dnw==} engines: {node: '>=18'} hasBin: true peerDependencies: @@ -2021,8 +2021,8 @@ packages: undici-types@6.21.0: resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} - undici@7.25.0: - resolution: {integrity: sha512-xXnp4kTyor2Zq+J1FfPI6Eq3ew5h6Vl0F/8d9XU5zZQf1tX9s2Su1/3PiMmUANFULpmksxkClamIZcaUqryHsQ==} + undici@7.28.0: + resolution: {integrity: sha512-cRZYrTDwWznlnRiPjggAGxZXanty6M8RV1ff8Wm4LWXBp7/IG8v5DnOm74DtUBp9OONpK75YlPnIjQqX0dBDtA==} engines: {node: '>=20.18.1'} unpipe@1.0.0: @@ -3275,7 +3275,7 @@ snapshots: '@relayburn/sdk-linux-arm64-gnu': 2.5.2 '@relayburn/sdk-linux-x64-gnu': 2.5.2 - '@relayfile/adapter-core@0.3.59(@relayfile/sdk@0.7.40)': + '@relayfile/adapter-core@0.3.60(@relayfile/sdk@0.7.40)': dependencies: '@relayfile/sdk': 0.7.40 '@scalar/postman-to-openapi': 0.6.3 @@ -3655,7 +3655,7 @@ snapshots: parse5: 7.3.0 parse5-htmlparser2-tree-adapter: 7.1.0 parse5-parser-stream: 7.1.2 - undici: 7.25.0 + undici: 7.28.0 whatwg-mimetype: 4.0.0 chownr@3.0.0: {} @@ -4426,7 +4426,7 @@ snapshots: undici-types@6.21.0: {} - undici@7.25.0: {} + undici@7.28.0: {} unpipe@1.0.0: {}