Skip to content

Commit c9a857b

Browse files
authored
Merge pull request #245 from AgentWorkforce/chore/adapter-core-0.3.60
chore(runtime): consume adapter-core writeback normalizer
2 parents c4fe7f1 + 898e35f commit c9a857b

4 files changed

Lines changed: 19 additions & 111 deletions

File tree

packages/persona-kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"lint": "tsc -p tsconfig.json --noEmit"
4242
},
4343
"dependencies": {
44-
"@relayfile/adapter-core": "^0.3.59",
44+
"@relayfile/adapter-core": "^0.3.60",
4545
"@relayfile/local-mount": "^0.7.24"
4646
},
4747
"devDependencies": {

packages/runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@agent-assistant/proactive": "^0.4.32",
5757
"@agent-relay/events": "^6.3.3",
5858
"@agentworkforce/persona-kit": "workspace:*",
59-
"@relayfile/adapter-core": "^0.3.59",
59+
"@relayfile/adapter-core": "^0.3.60",
6060
"agent-trajectories": "^0.5.3"
6161
}
6262
}

packages/runtime/src/clients/index.ts

Lines changed: 6 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import * as adapterVfsClient from '@relayfile/adapter-core/vfs-client';
21
import {
32
writeJsonFile as coreWriteJsonFile,
4-
RelayfileWritebackError,
3+
normalizeWritebackStatus,
4+
WritebackError,
55
type IntegrationClientOptions,
6-
type WritebackReceipt,
76
type WritebackResult
87
} from '@relayfile/adapter-core/vfs-client';
98

@@ -25,8 +24,12 @@ export {
2524
readTextFile,
2625
resolveMountRoot,
2726
RelayfileWritebackError,
27+
WritebackError,
28+
normalizeWritebackStatus,
2829
type RelayfileWritebackErrorOptions,
2930
type IntegrationClientOptions,
31+
type NormalizedWritebackState,
32+
type NormalizedWritebackStatus,
3033
type WritebackReceipt,
3134
type WritebackResult
3235
} from '@relayfile/adapter-core/vfs-client';
@@ -37,101 +40,6 @@ export {
3740
SandboxNotAvailableError
3841
} from '../errors.js';
3942

40-
export type NormalizedWritebackState =
41-
| 'succeeded'
42-
| 'no_receipt'
43-
| 'validation_failed'
44-
| 'readonly_rejected'
45-
| 'adapter_error'
46-
| 'ok';
47-
48-
export interface NormalizedWritebackStatus {
49-
state: NormalizedWritebackState;
50-
path: string;
51-
op?: 'create' | 'patch' | 'delete';
52-
id?: string;
53-
error?: string;
54-
field?: string;
55-
receipt?: WritebackReceipt;
56-
timestamp?: string;
57-
entry?: unknown;
58-
}
59-
60-
type AdapterVfsClientExtensions = {
61-
normalizeWritebackStatus?: (
62-
result?: WritebackResult,
63-
entry?: unknown
64-
) => NormalizedWritebackStatus;
65-
WritebackError?: new (normalized: NormalizedWritebackStatus) => RelayfileWritebackError &
66-
NormalizedWritebackStatus;
67-
};
68-
69-
class FallbackWritebackError extends RelayfileWritebackError {
70-
readonly state: NormalizedWritebackState;
71-
readonly path: string;
72-
readonly op?: 'create' | 'patch' | 'delete';
73-
readonly id?: string;
74-
readonly receipt?: WritebackReceipt;
75-
readonly error?: string;
76-
readonly field?: string;
77-
readonly timestamp?: string;
78-
79-
constructor(normalized: NormalizedWritebackStatus) {
80-
super({
81-
provider: 'writeback',
82-
operation: normalized.state,
83-
cause: normalized.error ? new Error(normalized.error) : undefined,
84-
retryable: false
85-
});
86-
this.name = 'WritebackError';
87-
this.message = `writeback ${normalized.state} ${normalized.path}${
88-
normalized.error ? `: ${normalized.error}` : ''
89-
}`;
90-
this.state = normalized.state;
91-
this.path = normalized.path;
92-
this.op = normalized.op;
93-
this.id = normalized.id;
94-
this.receipt = normalized.receipt;
95-
this.error = normalized.error;
96-
this.field = normalized.field;
97-
this.timestamp = normalized.timestamp;
98-
}
99-
}
100-
101-
const adapterExtensions = adapterVfsClient as AdapterVfsClientExtensions;
102-
103-
export const WritebackError = adapterExtensions.WritebackError ?? FallbackWritebackError;
104-
105-
export function normalizeWritebackStatus(
106-
result?: WritebackResult,
107-
entry?: unknown
108-
): NormalizedWritebackStatus {
109-
const normalize = adapterExtensions.normalizeWritebackStatus;
110-
if (normalize) return normalize(result, entry);
111-
112-
if (!result?.receipt) {
113-
return {
114-
state: 'no_receipt',
115-
path: result?.path ?? '',
116-
error: 'writeback produced no receipt'
117-
};
118-
}
119-
120-
const receipt = result.receipt;
121-
const id =
122-
receipt.id !== undefined
123-
? String(receipt.id)
124-
: receipt.created !== undefined
125-
? String(receipt.created)
126-
: undefined;
127-
return {
128-
state: 'succeeded',
129-
path: result.path,
130-
...(id ? { id } : {}),
131-
receipt
132-
};
133-
}
134-
13543
export async function writeJsonFile(
13644
client: IntegrationClientOptions,
13745
provider: string,

pnpm-lock.yaml

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)