@awcp/core 0.0.0-dev-202601300724

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.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * AWCP Error Codes
3
+ *
4
+ * Standard error codes defined in AWCP v1 specification
5
+ */
6
+ export declare const ErrorCodes: {
7
+ /** Remote declined collaboration */
8
+ readonly DECLINED: "DECLINED";
9
+ /** Missing dependency (e.g., sshfs not installed) */
10
+ readonly DEP_MISSING: "DEP_MISSING";
11
+ /** Workspace too large for remote mount collaboration */
12
+ readonly WORKSPACE_TOO_LARGE: "WORKSPACE_TOO_LARGE";
13
+ /** Mount point denied by policy */
14
+ readonly MOUNTPOINT_DENIED: "MOUNTPOINT_DENIED";
15
+ /** Lease expired before START */
16
+ readonly START_EXPIRED: "START_EXPIRED";
17
+ /** Lease expired during execution */
18
+ readonly EXPIRED: "EXPIRED";
19
+ /** Authentication failed */
20
+ readonly AUTH_FAILED: "AUTH_FAILED";
21
+ /** Mount operation failed */
22
+ readonly MOUNT_FAILED: "MOUNT_FAILED";
23
+ /** Task execution failed */
24
+ readonly TASK_FAILED: "TASK_FAILED";
25
+ /** Cancelled by user or system */
26
+ readonly CANCELLED: "CANCELLED";
27
+ };
28
+ export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
29
+ /**
30
+ * Base class for AWCP errors
31
+ */
32
+ export declare class AwcpError extends Error {
33
+ readonly code: ErrorCode;
34
+ readonly hint?: string | undefined;
35
+ readonly delegationId?: string | undefined;
36
+ constructor(code: ErrorCode, message: string, hint?: string | undefined, delegationId?: string | undefined);
37
+ toErrorMessage(): {
38
+ code: ErrorCode;
39
+ message: string;
40
+ hint: string | undefined;
41
+ };
42
+ }
43
+ /**
44
+ * Error: Remote declined the collaboration
45
+ */
46
+ export declare class DeclinedError extends AwcpError {
47
+ constructor(message: string, hint?: string, delegationId?: string);
48
+ }
49
+ /**
50
+ * Error: Missing required dependency
51
+ */
52
+ export declare class DependencyMissingError extends AwcpError {
53
+ readonly dependency: string;
54
+ constructor(dependency: string, hint?: string, delegationId?: string);
55
+ }
56
+ /**
57
+ * Error: Workspace too large
58
+ */
59
+ export declare class WorkspaceTooLargeError extends AwcpError {
60
+ readonly stats: {
61
+ estimatedBytes?: number;
62
+ fileCount?: number;
63
+ largestFileBytes?: number;
64
+ };
65
+ constructor(stats: {
66
+ estimatedBytes?: number;
67
+ fileCount?: number;
68
+ largestFileBytes?: number;
69
+ }, hint?: string, delegationId?: string);
70
+ }
71
+ /**
72
+ * Error: Mount point denied by policy
73
+ */
74
+ export declare class MountPointDeniedError extends AwcpError {
75
+ constructor(mountPoint: string, hint?: string, delegationId?: string);
76
+ }
77
+ /**
78
+ * Error: Mount operation failed
79
+ */
80
+ export declare class MountFailedError extends AwcpError {
81
+ constructor(reason: string, hint?: string, delegationId?: string);
82
+ }
83
+ /**
84
+ * Error: Task execution failed
85
+ */
86
+ export declare class TaskFailedError extends AwcpError {
87
+ constructor(reason: string, hint?: string, delegationId?: string);
88
+ }
89
+ /**
90
+ * Error: Lease expired
91
+ */
92
+ export declare class LeaseExpiredError extends AwcpError {
93
+ constructor(duringStart?: boolean, delegationId?: string);
94
+ }
95
+ /**
96
+ * Error: Authentication failed
97
+ */
98
+ export declare class AuthFailedError extends AwcpError {
99
+ constructor(reason?: string, hint?: string, delegationId?: string);
100
+ }
101
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,UAAU;IACrB,oCAAoC;;IAEpC,qDAAqD;;IAErD,yDAAyD;;IAEzD,mCAAmC;;IAEnC,iCAAiC;;IAEjC,qCAAqC;;IAErC,4BAA4B;;IAE5B,6BAA6B;;IAE7B,4BAA4B;;IAE5B,kCAAkC;;CAE1B,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU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AAM,EAAE,YAAY,CAAC,EAAE,MAAM;CASjE;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;CASjE;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;gBAE5C,WAAW,GAAE,OAAe,EAC5B,YAAY,CAAC,EAAE,MAAM;CAYxB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAE1C,MAAM,GAAE,MAAgC,EACxC,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM;CAUxB"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * AWCP Error Codes
3
+ *
4
+ * Standard error codes defined in AWCP v1 specification
5
+ */
6
+ export const ErrorCodes = {
7
+ /** Remote declined collaboration */
8
+ DECLINED: 'DECLINED',
9
+ /** Missing dependency (e.g., sshfs not installed) */
10
+ DEP_MISSING: 'DEP_MISSING',
11
+ /** Workspace too large for remote mount collaboration */
12
+ WORKSPACE_TOO_LARGE: 'WORKSPACE_TOO_LARGE',
13
+ /** Mount point denied by policy */
14
+ MOUNTPOINT_DENIED: 'MOUNTPOINT_DENIED',
15
+ /** Lease expired before START */
16
+ START_EXPIRED: 'START_EXPIRED',
17
+ /** Lease expired during execution */
18
+ EXPIRED: 'EXPIRED',
19
+ /** Authentication failed */
20
+ AUTH_FAILED: 'AUTH_FAILED',
21
+ /** Mount operation failed */
22
+ MOUNT_FAILED: 'MOUNT_FAILED',
23
+ /** Task execution failed */
24
+ TASK_FAILED: 'TASK_FAILED',
25
+ /** Cancelled by user or system */
26
+ CANCELLED: 'CANCELLED',
27
+ };
28
+ /**
29
+ * Base class for AWCP errors
30
+ */
31
+ export class AwcpError extends Error {
32
+ code;
33
+ hint;
34
+ delegationId;
35
+ constructor(code, message, hint, delegationId) {
36
+ super(message);
37
+ this.code = code;
38
+ this.hint = hint;
39
+ this.delegationId = delegationId;
40
+ this.name = 'AwcpError';
41
+ }
42
+ toErrorMessage() {
43
+ return {
44
+ code: this.code,
45
+ message: this.message,
46
+ hint: this.hint,
47
+ };
48
+ }
49
+ }
50
+ /**
51
+ * Error: Remote declined the collaboration
52
+ */
53
+ export class DeclinedError extends AwcpError {
54
+ constructor(message, hint, delegationId) {
55
+ super(ErrorCodes.DECLINED, message, hint, delegationId);
56
+ this.name = 'DeclinedError';
57
+ }
58
+ }
59
+ /**
60
+ * Error: Missing required dependency
61
+ */
62
+ export class DependencyMissingError extends AwcpError {
63
+ dependency;
64
+ constructor(dependency, hint, delegationId) {
65
+ super(ErrorCodes.DEP_MISSING, `Missing required dependency: ${dependency}`, hint ?? `Please install ${dependency} and try again`, delegationId);
66
+ this.dependency = dependency;
67
+ this.name = 'DependencyMissingError';
68
+ }
69
+ }
70
+ /**
71
+ * Error: Workspace too large
72
+ */
73
+ export class WorkspaceTooLargeError extends AwcpError {
74
+ stats;
75
+ constructor(stats, hint, delegationId) {
76
+ super(ErrorCodes.WORKSPACE_TOO_LARGE, 'Workspace exceeds size limits for remote mount collaboration', hint ?? 'Consider selecting a smaller subdirectory or excluding large files', delegationId);
77
+ this.stats = stats;
78
+ this.name = 'WorkspaceTooLargeError';
79
+ }
80
+ }
81
+ /**
82
+ * Error: Mount point denied by policy
83
+ */
84
+ export class MountPointDeniedError extends AwcpError {
85
+ constructor(mountPoint, hint, delegationId) {
86
+ super(ErrorCodes.MOUNTPOINT_DENIED, `Mount point denied by policy: ${mountPoint}`, hint, delegationId);
87
+ this.name = 'MountPointDeniedError';
88
+ }
89
+ }
90
+ /**
91
+ * Error: Mount operation failed
92
+ */
93
+ export class MountFailedError extends AwcpError {
94
+ constructor(reason, hint, delegationId) {
95
+ super(ErrorCodes.MOUNT_FAILED, `Mount failed: ${reason}`, hint, delegationId);
96
+ this.name = 'MountFailedError';
97
+ }
98
+ }
99
+ /**
100
+ * Error: Task execution failed
101
+ */
102
+ export class TaskFailedError extends AwcpError {
103
+ constructor(reason, hint, delegationId) {
104
+ super(ErrorCodes.TASK_FAILED, `Task failed: ${reason}`, hint, delegationId);
105
+ this.name = 'TaskFailedError';
106
+ }
107
+ }
108
+ /**
109
+ * Error: Lease expired
110
+ */
111
+ export class LeaseExpiredError extends AwcpError {
112
+ constructor(duringStart = false, delegationId) {
113
+ super(duringStart ? ErrorCodes.START_EXPIRED : ErrorCodes.EXPIRED, duringStart
114
+ ? 'Lease expired before START message was received'
115
+ : 'Lease expired during task execution', undefined, delegationId);
116
+ this.name = 'LeaseExpiredError';
117
+ }
118
+ }
119
+ /**
120
+ * Error: Authentication failed
121
+ */
122
+ export class AuthFailedError extends AwcpError {
123
+ constructor(reason = 'Authentication failed', hint, delegationId) {
124
+ super(ErrorCodes.AUTH_FAILED, reason, hint ?? 'Check your API key or credentials', delegationId);
125
+ this.name = 'AuthFailedError';
126
+ }
127
+ }
128
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,oCAAoC;IACpC,QAAQ,EAAE,UAAU;IACpB,qDAAqD;IACrD,WAAW,EAAE,aAAa;IAC1B,yDAAyD;IACzD,mBAAmB,EAAE,qBAAqB;IAC1C,mCAAmC;IACnC,iBAAiB,EAAE,mBAAmB;IACtC,iCAAiC;IACjC,aAAa,EAAE,eAAe;IAC9B,qCAAqC;IACrC,OAAO,EAAE,SAAS;IAClB,4BAA4B;IAC5B,WAAW,EAAE,aAAa;IAC1B,6BAA6B;IAC7B,YAAY,EAAE,cAAc;IAC5B,4BAA4B;IAC5B,WAAW,EAAE,aAAa;IAC1B,kCAAkC;IAClC,SAAS,EAAE,WAAW;CACd,CAAC;AAIX;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEhB;IAEA;IACA;IAJlB,YACkB,IAAe,EA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C,WAAW,EACtB,MAAM,EACN,IAAI,IAAI,mCAAmC,EAC3C,YAAY,CACb,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @awcp/core
3
+ *
4
+ * AWCP Protocol Core - Types, State Machine, and Error Definitions
5
+ */
6
+ export * from './types/index.js';
7
+ export { DelegationStateMachine, isTerminalState, isValidTransition, createDelegation, applyMessageToDelegation, type DelegationEvent, type TransitionResult, } from './state-machine/index.js';
8
+ export * from './errors/index.js';
9
+ export { PROTOCOL_VERSION } from './types/messages.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAGlC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @awcp/core
3
+ *
4
+ * AWCP Protocol Core - Types, State Machine, and Error Definitions
5
+ */
6
+ // Types
7
+ export * from './types/index.js';
8
+ // State Machine
9
+ export { DelegationStateMachine, isTerminalState, isValidTransition, createDelegation, applyMessageToDelegation, } from './state-machine/index.js';
10
+ // Errors
11
+ export * from './errors/index.js';
12
+ // Protocol version constant
13
+ export { PROTOCOL_VERSION } from './types/messages.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,gBAAgB;AAChB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,GAGzB,MAAM,0BAA0B,CAAC;AAElC,SAAS;AACT,cAAc,mBAAmB,CAAC;AAElC,4BAA4B;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,86 @@
1
+ import type { DelegationState, AwcpMessage, Delegation, InviteMessage, AcceptMessage, StartMessage, DoneMessage, ErrorMessage } from '../types/messages.js';
2
+ /**
3
+ * Check if a state is terminal (no further transitions possible)
4
+ */
5
+ export declare function isTerminalState(state: DelegationState): boolean;
6
+ /**
7
+ * Check if a state transition is valid
8
+ */
9
+ export declare function isValidTransition(from: DelegationState, to: DelegationState): boolean;
10
+ /**
11
+ * Events that can trigger state transitions
12
+ */
13
+ export type DelegationEvent = {
14
+ type: 'SEND_INVITE';
15
+ message: InviteMessage;
16
+ } | {
17
+ type: 'RECEIVE_ACCEPT';
18
+ message: AcceptMessage;
19
+ } | {
20
+ type: 'SEND_START';
21
+ message: StartMessage;
22
+ } | {
23
+ type: 'MOUNT_COMPLETE';
24
+ } | {
25
+ type: 'RECEIVE_DONE';
26
+ message: DoneMessage;
27
+ } | {
28
+ type: 'RECEIVE_ERROR';
29
+ message: ErrorMessage;
30
+ } | {
31
+ type: 'SEND_ERROR';
32
+ message: ErrorMessage;
33
+ } | {
34
+ type: 'CANCEL';
35
+ } | {
36
+ type: 'EXPIRE';
37
+ };
38
+ /**
39
+ * Result of a state transition
40
+ */
41
+ export interface TransitionResult {
42
+ success: boolean;
43
+ newState: DelegationState;
44
+ error?: string;
45
+ }
46
+ /**
47
+ * Delegation state machine
48
+ *
49
+ * Manages state transitions for a single delegation
50
+ */
51
+ export declare class DelegationStateMachine {
52
+ private state;
53
+ constructor(initialState?: DelegationState);
54
+ /**
55
+ * Get current state
56
+ */
57
+ getState(): DelegationState;
58
+ /**
59
+ * Check if delegation is in a terminal state
60
+ */
61
+ isTerminal(): boolean;
62
+ /**
63
+ * Process an event and transition state
64
+ */
65
+ transition(event: DelegationEvent): TransitionResult;
66
+ /**
67
+ * Force state (use with caution, mainly for restoration)
68
+ */
69
+ forceState(state: DelegationState): void;
70
+ private getTargetState;
71
+ }
72
+ /**
73
+ * Create a new delegation record
74
+ */
75
+ export declare function createDelegation(params: {
76
+ id: string;
77
+ peerUrl: string;
78
+ localDir: string;
79
+ task: Delegation['task'];
80
+ leaseConfig: Delegation['leaseConfig'];
81
+ }): Delegation;
82
+ /**
83
+ * Update delegation with message data
84
+ */
85
+ export declare function applyMessageToDelegation(delegation: Delegation, message: AwcpMessage): Delegation;
86
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state-machine/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,EACb,MAAM,sBAAsB,CAAC;AAiB9B;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAE/D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,EACrB,EAAE,EAAE,eAAe,GAClB,OAAO,CAET;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,KAAK,CAA8B;gBAE/B,YAAY,CAAC,EAAE,eAAe;IAM1C;;OAEG;IACH,QAAQ,IAAI,eAAe;IAI3B;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB;IA0BpD;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAIxC,OAAO,CAAC,cAAc;CAkCvB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACzB,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC;CACxC,GAAG,UAAU,CAYb;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,WAAW,GACnB,UAAU,CA+BZ"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Valid state transitions for delegation lifecycle
3
+ */
4
+ const STATE_TRANSITIONS = {
5
+ created: ['invited', 'error', 'cancelled'],
6
+ invited: ['accepted', 'error', 'cancelled', 'expired'],
7
+ accepted: ['started', 'error', 'cancelled', 'expired'],
8
+ started: ['running', 'error', 'cancelled'],
9
+ running: ['completed', 'error', 'cancelled', 'expired'],
10
+ completed: [], // Terminal state
11
+ error: [], // Terminal state
12
+ cancelled: [], // Terminal state
13
+ expired: [], // Terminal state
14
+ };
15
+ /**
16
+ * Check if a state is terminal (no further transitions possible)
17
+ */
18
+ export function isTerminalState(state) {
19
+ return STATE_TRANSITIONS[state].length === 0;
20
+ }
21
+ /**
22
+ * Check if a state transition is valid
23
+ */
24
+ export function isValidTransition(from, to) {
25
+ return STATE_TRANSITIONS[from].includes(to);
26
+ }
27
+ /**
28
+ * Delegation state machine
29
+ *
30
+ * Manages state transitions for a single delegation
31
+ */
32
+ export class DelegationStateMachine {
33
+ state = 'created';
34
+ constructor(initialState) {
35
+ if (initialState) {
36
+ this.state = initialState;
37
+ }
38
+ }
39
+ /**
40
+ * Get current state
41
+ */
42
+ getState() {
43
+ return this.state;
44
+ }
45
+ /**
46
+ * Check if delegation is in a terminal state
47
+ */
48
+ isTerminal() {
49
+ return isTerminalState(this.state);
50
+ }
51
+ /**
52
+ * Process an event and transition state
53
+ */
54
+ transition(event) {
55
+ const targetState = this.getTargetState(event);
56
+ if (!targetState) {
57
+ return {
58
+ success: false,
59
+ newState: this.state,
60
+ error: `Invalid event ${event.type} for state ${this.state}`,
61
+ };
62
+ }
63
+ if (!isValidTransition(this.state, targetState)) {
64
+ return {
65
+ success: false,
66
+ newState: this.state,
67
+ error: `Invalid transition from ${this.state} to ${targetState}`,
68
+ };
69
+ }
70
+ this.state = targetState;
71
+ return {
72
+ success: true,
73
+ newState: this.state,
74
+ };
75
+ }
76
+ /**
77
+ * Force state (use with caution, mainly for restoration)
78
+ */
79
+ forceState(state) {
80
+ this.state = state;
81
+ }
82
+ getTargetState(event) {
83
+ switch (event.type) {
84
+ case 'SEND_INVITE':
85
+ return this.state === 'created' ? 'invited' : null;
86
+ case 'RECEIVE_ACCEPT':
87
+ return this.state === 'invited' ? 'accepted' : null;
88
+ case 'SEND_START':
89
+ return this.state === 'accepted' ? 'started' : null;
90
+ case 'MOUNT_COMPLETE':
91
+ return this.state === 'started' ? 'running' : null;
92
+ case 'RECEIVE_DONE':
93
+ return this.state === 'running' ? 'completed' : null;
94
+ case 'RECEIVE_ERROR':
95
+ case 'SEND_ERROR':
96
+ return isTerminalState(this.state) ? null : 'error';
97
+ case 'CANCEL':
98
+ return isTerminalState(this.state) ? null : 'cancelled';
99
+ case 'EXPIRE':
100
+ // Can expire from invited, accepted, or running states
101
+ return ['invited', 'accepted', 'running'].includes(this.state)
102
+ ? 'expired'
103
+ : null;
104
+ default:
105
+ return null;
106
+ }
107
+ }
108
+ }
109
+ /**
110
+ * Create a new delegation record
111
+ */
112
+ export function createDelegation(params) {
113
+ const now = new Date().toISOString();
114
+ return {
115
+ id: params.id,
116
+ state: 'created',
117
+ peerUrl: params.peerUrl,
118
+ localDir: params.localDir,
119
+ task: params.task,
120
+ leaseConfig: params.leaseConfig,
121
+ createdAt: now,
122
+ updatedAt: now,
123
+ };
124
+ }
125
+ /**
126
+ * Update delegation with message data
127
+ */
128
+ export function applyMessageToDelegation(delegation, message) {
129
+ const updated = { ...delegation, updatedAt: new Date().toISOString() };
130
+ switch (message.type) {
131
+ case 'ACCEPT':
132
+ updated.executorMount = message.executorMount;
133
+ updated.executorConstraints = message.executorConstraints;
134
+ break;
135
+ case 'START':
136
+ updated.activeLease = message.lease;
137
+ break;
138
+ case 'DONE':
139
+ updated.result = {
140
+ summary: message.finalSummary,
141
+ highlights: message.highlights,
142
+ notes: message.notes,
143
+ };
144
+ break;
145
+ case 'ERROR':
146
+ updated.error = {
147
+ code: message.code,
148
+ message: message.message,
149
+ hint: message.hint,
150
+ };
151
+ break;
152
+ }
153
+ return updated;
154
+ }
155
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state-machine/index.ts"],"names":[],"mappings":"AAWA;;GAEG;AAC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;IAEvE,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;YAC9C,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAC1D,MAAM;QAER,KAAK,OAAO;YACV,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;YACpC,MAAM;QAER,KAAK,MAAM;YACT,OAAO,CAAC,MAAM,GAAG;gBACf,OAAO,EAAE,OAAO,CAAC,YAAY;gBAC7B,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC;YACF,MAAM;QAER,KAAK,OAAO;YACV,OAAO,CAAC,KAAK,GAAG;gBACd,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC;YACF,MAAM;IACV,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './messages.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './messages.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * AWCP Protocol Version
3
+ */
4
+ export declare const PROTOCOL_VERSION: "1";
5
+ /**
6
+ * Message Types for AWCP Protocol
7
+ */
8
+ export type MessageType = 'INVITE' | 'ACCEPT' | 'START' | 'DONE' | 'ERROR';
9
+ /**
10
+ * Access modes for workspace delegation
11
+ */
12
+ export type AccessMode = 'ro' | 'rw';
13
+ /**
14
+ * Authentication types for AWCP protocol-level auth
15
+ */
16
+ export type AuthType = 'api_key' | 'bearer' | 'oauth2' | 'custom';
17
+ /**
18
+ * Authentication credential in INVITE message
19
+ */
20
+ export interface AuthCredential {
21
+ type: AuthType;
22
+ credential: string;
23
+ metadata?: Record<string, string>;
24
+ }
25
+ /**
26
+ * Transport types for data plane
27
+ */
28
+ export type TransportType = 'sshfs';
29
+ /**
30
+ * Delegation lifecycle states
31
+ */
32
+ export type DelegationState = 'created' | 'invited' | 'accepted' | 'started' | 'running' | 'completed' | 'error' | 'cancelled' | 'expired';
33
+ /**
34
+ * Task description for delegation
35
+ */
36
+ export interface TaskSpec {
37
+ /** Short description for logging/listing */
38
+ description: string;
39
+ /** Full task prompt with goals and constraints */
40
+ prompt: string;
41
+ }
42
+ /**
43
+ * Lease configuration
44
+ */
45
+ export interface LeaseConfig {
46
+ /** Time-to-live in seconds */
47
+ ttlSeconds: number;
48
+ /** Access mode */
49
+ accessMode: AccessMode;
50
+ }
51
+ /**
52
+ * Active lease information (after START)
53
+ */
54
+ export interface ActiveLease {
55
+ /** Absolute expiration time (ISO 8601) */
56
+ expiresAt: string;
57
+ /** Effective access mode */
58
+ accessMode: AccessMode;
59
+ }
60
+ /**
61
+ * Workspace specification in INVITE
62
+ */
63
+ export interface WorkspaceSpec {
64
+ /** Logical export name (not real path), e.g., "awcp/<id>" */
65
+ exportName: string;
66
+ }
67
+ /**
68
+ * Requirements for Executor to check
69
+ */
70
+ export interface Requirements {
71
+ /** Transport type (default: sshfs) */
72
+ transport?: TransportType;
73
+ }
74
+ /**
75
+ * Executor mount specification in ACCEPT
76
+ */
77
+ export interface ExecutorMount {
78
+ /** Local absolute path on Executor, determined by Executor's policy */
79
+ mountPoint: string;
80
+ }
81
+ /**
82
+ * Sandbox profile - capability declaration by Executor
83
+ */
84
+ export interface SandboxProfile {
85
+ /** Whether tools are restricted to mount point CWD */
86
+ cwdOnly?: boolean;
87
+ /** Whether network access is allowed */
88
+ allowNetwork?: boolean;
89
+ /** Whether command execution is allowed */
90
+ allowExec?: boolean;
91
+ }
92
+ /**
93
+ * Executor constraints in ACCEPT
94
+ */
95
+ export interface ExecutorConstraints {
96
+ /** Actually accepted access mode (may be downgraded) */
97
+ acceptedAccessMode?: AccessMode;
98
+ /** Maximum TTL Executor allows */
99
+ maxTtlSeconds?: number;
100
+ /** Self-declared sandbox constraints */
101
+ sandboxProfile?: SandboxProfile;
102
+ }
103
+ /**
104
+ * SSH endpoint for SSHFS transport
105
+ */
106
+ export interface SshEndpoint {
107
+ host: string;
108
+ port: number;
109
+ user: string;
110
+ }
111
+ /**
112
+ * Mount information in START message
113
+ */
114
+ export interface MountInfo {
115
+ /** Transport type */
116
+ transport: TransportType;
117
+ /** Connection endpoint */
118
+ endpoint: SshEndpoint;
119
+ /** Export path or locator token */
120
+ exportLocator: string;
121
+ /** Temporary credential (SSH key or token) */
122
+ credential: string;
123
+ /** Optional mount parameters */
124
+ mountOptions?: Record<string, string>;
125
+ }
126
+ /**
127
+ * Base message structure
128
+ */
129
+ export interface BaseMessage {
130
+ version: typeof PROTOCOL_VERSION;
131
+ type: MessageType;
132
+ delegationId: string;
133
+ }
134
+ /**
135
+ * INVITE message: Delegator → Executor
136
+ * Initiates collaboration request
137
+ */
138
+ export interface InviteMessage extends BaseMessage {
139
+ type: 'INVITE';
140
+ task: TaskSpec;
141
+ lease: LeaseConfig;
142
+ workspace: WorkspaceSpec;
143
+ requirements?: Requirements;
144
+ /**
145
+ * Optional authentication for paid/restricted Executor services.
146
+ * Executor can validate this in onInvite hook before accepting.
147
+ */
148
+ auth?: AuthCredential;
149
+ }
150
+ /**
151
+ * ACCEPT message: Executor → Delegator
152
+ * Confirms acceptance with mount point
153
+ */
154
+ export interface AcceptMessage extends BaseMessage {
155
+ type: 'ACCEPT';
156
+ executorMount: ExecutorMount;
157
+ executorConstraints?: ExecutorConstraints;
158
+ }
159
+ /**
160
+ * START message: Delegator → Executor
161
+ * Authorizes and provides credentials
162
+ */
163
+ export interface StartMessage extends BaseMessage {
164
+ type: 'START';
165
+ lease: ActiveLease;
166
+ mount: MountInfo;
167
+ }
168
+ /**
169
+ * DONE message: Executor → Delegator
170
+ * Reports successful completion
171
+ */
172
+ export interface DoneMessage extends BaseMessage {
173
+ type: 'DONE';
174
+ /** Summary of what was accomplished */
175
+ finalSummary: string;
176
+ /** Files Executor suggests Delegator to review */
177
+ highlights?: string[];
178
+ /** Additional notes */
179
+ notes?: string;
180
+ }
181
+ /**
182
+ * ERROR message: Either direction
183
+ * Reports failure or rejection
184
+ */
185
+ export interface ErrorMessage extends BaseMessage {
186
+ type: 'ERROR';
187
+ /** Error code */
188
+ code: string;
189
+ /** Human-readable description */
190
+ message: string;
191
+ /** Suggested fix */
192
+ hint?: string;
193
+ }
194
+ /**
195
+ * Union type for all AWCP messages
196
+ */
197
+ export type AwcpMessage = InviteMessage | AcceptMessage | StartMessage | DoneMessage | ErrorMessage;
198
+ /**
199
+ * Delegation record - full state of a delegation
200
+ */
201
+ export interface Delegation {
202
+ id: string;
203
+ state: DelegationState;
204
+ peerUrl: string;
205
+ localDir: string;
206
+ exportPath?: string;
207
+ task: TaskSpec;
208
+ leaseConfig: LeaseConfig;
209
+ activeLease?: ActiveLease;
210
+ executorMount?: ExecutorMount;
211
+ executorConstraints?: ExecutorConstraints;
212
+ result?: {
213
+ summary: string;
214
+ highlights?: string[];
215
+ notes?: string;
216
+ };
217
+ error?: {
218
+ code: string;
219
+ message: string;
220
+ hint?: string;
221
+ };
222
+ createdAt: string;
223
+ updatedAt: string;
224
+ }
225
+ /** @deprecated Use ExecutorMount instead */
226
+ export type RemoteMount = ExecutorMount;
227
+ /** @deprecated Use ExecutorConstraints instead */
228
+ export type RemoteConstraints = ExecutorConstraints;
229
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/types/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f,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC;AAExC,kDAAkD;AAClD,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * AWCP Protocol Version
3
+ */
4
+ export const PROTOCOL_VERSION = '1';
5
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/types/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAY,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@awcp/core",
3
+ "version": "0.0.0-dev-202601300724",
4
+ "description": "AWCP Protocol Core - Types, State Machine, and Error Definitions",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./types": {
14
+ "types": "./dist/types/index.d.ts",
15
+ "import": "./dist/types/index.js"
16
+ },
17
+ "./errors": {
18
+ "types": "./dist/errors/index.d.ts",
19
+ "import": "./dist/errors/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.build.json",
28
+ "clean": "rm -rf dist *.tsbuildinfo",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest"
31
+ },
32
+ "keywords": [
33
+ "awcp",
34
+ "agent",
35
+ "protocol",
36
+ "a2a"
37
+ ],
38
+ "license": "Apache-2.0",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/anthropics/awcp.git",
42
+ "directory": "packages/core"
43
+ }
44
+ }