@agent-relay/core-bridge 17.2.1 → 18.1.0

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.
package/dist/errors.js ADDED
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Every error kind the core can return in `error.data.kind`
3
+ * (`crates/relay-node/src/relay/protocol.rs` `ErrorKind`). A kind may be
4
+ * added without a bridge version bump, so {@link ErrorKind} also admits any
5
+ * other string.
6
+ */
7
+ export const ERROR_KINDS = [
8
+ 'parse_error',
9
+ 'invalid_request',
10
+ 'method_not_found',
11
+ 'invalid_params',
12
+ 'handshake_required',
13
+ 'bridge_version_mismatch',
14
+ 'not_signed_in',
15
+ 'refused',
16
+ 'relaycast_unreachable',
17
+ 'relaycast_refused',
18
+ 'unauthorized',
19
+ 'plan_limit_exceeded',
20
+ 'rate_limited',
21
+ 'not_found',
22
+ 'conflict',
23
+ 'shutting_down',
24
+ 'busy',
25
+ 'store_failed',
26
+ 'cloud_failed',
27
+ 'cloud_refused',
28
+ 'fleet_unavailable',
29
+ 'internal',
30
+ ];
31
+ /**
32
+ * Every typed reason the core gives with a `refused` error in
33
+ * `error.data.reason` (`protocol.rs` `RefusalReason`). None is retryable.
34
+ */
35
+ export const REFUSAL_REASONS = [
36
+ 'service_unknown',
37
+ 'service_disabled',
38
+ 'service_expired',
39
+ 'workspace_mismatch',
40
+ 'not_owner',
41
+ 'outside_scope',
42
+ 'management_peer',
43
+ ];
44
+ /** The base of every error this package throws; `code` names the class of failure. */
45
+ export class CoreBridgeError extends Error {
46
+ code;
47
+ constructor(code, message, options) {
48
+ super(message, options);
49
+ this.name = new.target.name;
50
+ this.code = code;
51
+ }
52
+ }
53
+ /** Nothing answers at the socket: the file is missing, the connection failed, or connecting timed out. */
54
+ export class CoreNotRunningError extends CoreBridgeError {
55
+ socket;
56
+ constructor(socket, message, options) {
57
+ super('core_not_running', message, options);
58
+ this.socket = socket;
59
+ }
60
+ }
61
+ /** The socket or its directory could have been planted by someone else; the client refused to connect. */
62
+ export class CoreUntrustedError extends CoreBridgeError {
63
+ reason;
64
+ constructor(reason, message) {
65
+ super('core_untrusted', message);
66
+ this.reason = reason;
67
+ }
68
+ }
69
+ /** What answered at the socket did not greet like the Agent Relay core. */
70
+ export class NotACoreError extends CoreBridgeError {
71
+ constructor(message) {
72
+ super('not_a_core', message);
73
+ }
74
+ }
75
+ /** The core speaks a different bridge version and refused this client. */
76
+ export class BridgeVersionMismatchError extends CoreBridgeError {
77
+ /** The bridge version this client sent. */
78
+ clientVersion;
79
+ /** The core's own message, safe to show a person. */
80
+ coreMessage;
81
+ constructor(clientVersion, coreMessage, message, options) {
82
+ super('bridge_version_mismatch', message, options);
83
+ this.clientVersion = clientVersion;
84
+ this.coreMessage = coreMessage;
85
+ }
86
+ }
87
+ /** The core answered a call with a JSON-RPC error. */
88
+ export class CoreRpcError extends CoreBridgeError {
89
+ /** The JSON-RPC numeric code. */
90
+ rpcCode;
91
+ /** The stable machine-readable kind from `error.data.kind`. */
92
+ kind;
93
+ /** Whether repeating the same request later can succeed. */
94
+ retryable;
95
+ /** With `plan_limit_exceeded`, the counters when the core had them. */
96
+ planLimit;
97
+ /** With `refused`, the typed reason from `error.data.reason` when the core gave one. */
98
+ reason;
99
+ constructor(message, details = {}) {
100
+ super('rpc_error', message);
101
+ this.rpcCode = details.rpcCode;
102
+ this.kind = details.kind;
103
+ this.retryable = details.retryable ?? false;
104
+ this.planLimit = details.planLimit;
105
+ this.reason = details.reason;
106
+ }
107
+ }
108
+ /**
109
+ * @deprecated Use {@link CoreRpcError}; this alias is removed in the next release.
110
+ */
111
+ export const CoreCallError = CoreRpcError;
112
+ /** The core did not answer a call in time. */
113
+ export class CoreTimeoutError extends CoreBridgeError {
114
+ method;
115
+ constructor(method) {
116
+ super('timeout', `The Agent Relay core did not answer ${method} in time.`);
117
+ this.method = method;
118
+ }
119
+ }
120
+ /** The core sent a line longer than `MAX_REPLY_BYTES`; the connection was closed. */
121
+ export class CoreReplyTooLargeError extends CoreBridgeError {
122
+ constructor() {
123
+ super('reply_too_large', 'The Agent Relay core sent an oversized reply.');
124
+ }
125
+ }
126
+ /** A request line would exceed `MAX_REQUEST_BYTES`; it was not sent and the connection stays open. */
127
+ export class CoreRequestTooLargeError extends CoreBridgeError {
128
+ method;
129
+ bytes;
130
+ constructor(method, bytes, limit) {
131
+ super('request_too_large', `The ${method} request is ${bytes} bytes; the Agent Relay core reads at most ${limit}.`);
132
+ this.method = method;
133
+ this.bytes = bytes;
134
+ }
135
+ }
136
+ /** The connection is closed: a call after close, or the connection ended while calls were pending. */
137
+ export class CoreClosedError extends CoreBridgeError {
138
+ constructor(message = 'The Agent Relay core closed the connection.', options) {
139
+ super('closed', message, options);
140
+ }
141
+ }
142
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,gBAAgB;IAChB,oBAAoB;IACpB,yBAAyB;IACzB,eAAe;IACf,SAAS;IACT,uBAAuB;IACvB,mBAAmB;IACnB,cAAc;IACd,qBAAqB;IACrB,cAAc;IACd,WAAW;IACX,UAAU;IACV,eAAe;IACf,MAAM;IACN,cAAc;IACd,cAAc;IACd,eAAe;IACf,mBAAmB;IACnB,UAAU;CACF,CAAC;AAaX;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;IACjB,oBAAoB;IACpB,WAAW;IACX,eAAe;IACf,iBAAiB;CACT,CAAC;AAQX,sFAAsF;AACtF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAS;IACtB,YAAY,IAAY,EAAE,OAAe,EAAE,OAA6B;QACtE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;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,GAAG,6CAA6C,EAAE,OAA6B;QAChG,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ export { BRIDGE_VERSION, CORE_SOCKET_ENV, MAX_REPLY_BYTES, MAX_REQUEST_BYTES, coreSocketPath, pipeName, } from './paths.js';
2
+ export { connectCore, tryConnectCore, type CallOptions, type ConnectOptions, type CoreClient, type CoreEvent, type HelloResult, type Topic, } from './client.js';
3
+ export { BridgeVersionMismatchError, CoreBridgeError, CoreCallError, CoreClosedError, CoreNotRunningError, CoreReplyTooLargeError, CoreRequestTooLargeError, CoreRpcError, CoreTimeoutError, CoreUntrustedError, NotACoreError, type ErrorKind, type PlanLimit, type RefusalReason, } from './errors.js';
4
+ export { CALLER_AUTH_SCHEME, CALLER_AUTHENTICATE_METHOD, CALLER_CHALLENGE_METHOD, CALLER_CHALLENGE_TTL_MS, CALLER_FILE_SCHEMA, CALLER_FILE_SCHEMAS, CALLER_TRANSCRIPT_DOMAIN, CALLER_TRANSCRIPT_VERSION, CallerCredential, MAX_CALLER_FILE_BYTES, REQUIRED_SERVICE_CALLER_METHODS, authenticate, callerTranscript, readCallerCredential, readCallerDescriptor, requireServiceCallerMethods, type CallerAuthenticateParams, type CallerAuthRoute, type CallerBound, type CallerChallenge, type CallerChallengeParams, type CallerFileAccount, type CallerFileDescriptor, type CallerFilePublisher, type CallerFileWorkspace, type CallerInboxRoute, type CallerTranscriptInput, } from './auth.js';
5
+ export { DEFAULT_SPAWN_ACTION_TIMEOUT_MS, isReleaseConfirmed, newIdempotencyKey, spawnInvoke, spawnRelease, spawnStatus, spawnTargets, type SpawnActionOptions, type SpawnControlAction, type SpawnControlInvocation, type SpawnControlTarget, type SpawnErrorCode, type SpawnInvokeParams, type SpawnReleaseParams, type SpawnStatus, type SpawnStatusParams, type SpawnTargets, } from './spawn.js';
6
+ export { INBOX_FAILURE_CODES, INBOX_NEXT_CALL_GRACE_MS, MAX_INBOX_NEXT_TIMEOUT_MS, SERVICE_CALLER_DISCONNECT_METHOD, SERVICE_CALLER_IDENTITY_METHOD, SERVICE_CALLER_INBOX_ACK_METHOD, SERVICE_CALLER_INBOX_CLOSE_METHOD, SERVICE_CALLER_INBOX_FAIL_METHOD, SERVICE_CALLER_INBOX_NEXT_METHOD, SERVICE_CALLER_INBOX_OPEN_METHOD, assertServiceCallerIdentity, serviceCallerDisconnect, serviceCallerIdentity, serviceCallerInboxAck, serviceCallerInboxClose, serviceCallerInboxFail, serviceCallerInboxNext, serviceCallerInboxOpen, type CallerIdentity, type CallerNode, type CallerPublisher, type InboxDelivery, type InboxFailure, type InboxFailureCode, type InboxNext, type InboxOpened, type InboxSender, type InboxSettleAction, type InboxSettled, type InboxSettleState, } from './service-callers.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,KAAK,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,E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 +1,7 @@
1
+ export { BRIDGE_VERSION, CORE_SOCKET_ENV, MAX_REPLY_BYTES, MAX_REQUEST_BYTES, coreSocketPath, pipeName, } from './paths.js';
2
+ export { connectCore, tryConnectCore, } from './client.js';
3
+ export { BridgeVersionMismatchError, CoreBridgeError, CoreCallError, CoreClosedError, CoreNotRunningError, CoreReplyTooLargeError, CoreRequestTooLargeError, CoreRpcError, CoreTimeoutError, CoreUntrustedError, NotACoreError, } from './errors.js';
4
+ export { CALLER_AUTH_SCHEME, CALLER_AUTHENTICATE_METHOD, CALLER_CHALLENGE_METHOD, CALLER_CHALLENGE_TTL_MS, CALLER_FILE_SCHEMA, CALLER_FILE_SCHEMAS, CALLER_TRANSCRIPT_DOMAIN, CALLER_TRANSCRIPT_VERSION, CallerCredential, MAX_CALLER_FILE_BYTES, REQUIRED_SERVICE_CALLER_METHODS, authenticate, callerTranscript, readCallerCredential, readCallerDescriptor, requireServiceCallerMethods, } from './auth.js';
5
+ export { DEFAULT_SPAWN_ACTION_TIMEOUT_MS, isReleaseConfirmed, newIdempotencyKey, spawnInvoke, spawnRelease, spawnStatus, spawnTargets, } from './spawn.js';
6
+ export { INBOX_FAILURE_CODES, INBOX_NEXT_CALL_GRACE_MS, MAX_INBOX_NEXT_TIMEOUT_MS, SERVICE_CALLER_DISCONNECT_METHOD, SERVICE_CALLER_IDENTITY_METHOD, SERVICE_CALLER_INBOX_ACK_METHOD, SERVICE_CALLER_INBOX_CLOSE_METHOD, SERVICE_CALLER_INBOX_FAIL_METHOD, SERVICE_CALLER_INBOX_NEXT_METHOD, SERVICE_CALLER_INBOX_OPEN_METHOD, assertServiceCallerIdentity, serviceCallerDisconnect, serviceCallerIdentity, serviceCallerInboxAck, serviceCallerInboxClose, serviceCallerInboxFail, serviceCallerInboxNext, serviceCallerInboxOpen, } from './service-callers.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,cAAc,GAOf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,GAId,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,+BAA+B,EAC/B,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,GAY5B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,GAWb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,8BAA8B,EAC9B,+BAA+B,EAC/B,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,2BAA2B,EAC3B,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,GAavB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /** The bridge version this client speaks (`crates/relay-node/src/relay/protocol.rs`). */
2
+ export declare const BRIDGE_VERSION = 2;
3
+ /** Moves the core's bridge socket, for the core and its clients alike. */
4
+ export declare const CORE_SOCKET_ENV = "AGENT_RELAY_CORE_SOCKET";
5
+ /** The longest request line the core reads (`protocol.rs` `MAX_FRAME_BYTES`), without its newline. */
6
+ export declare const MAX_REQUEST_BYTES: number;
7
+ /** The longest reply or event line this client buffers (`protocol.rs` `MAX_REPLY_BYTES`), without its newline. */
8
+ export declare const MAX_REPLY_BYTES: number;
9
+ /**
10
+ * The core's bridge socket, resolved as the core resolves it: an absolute
11
+ * `AGENT_RELAY_CORE_SOCKET`, a relative one beside the default, else
12
+ * `<home>/.agentworkforce/desktop/core.sock`.
13
+ * @param env - Environment to read the override from (default `process.env`)
14
+ * @param home - The user's home directory (default `os.homedir()`)
15
+ * @returns Absolute socket path
16
+ */
17
+ export declare function coreSocketPath(env?: NodeJS.ProcessEnv, home?: string): string;
18
+ /**
19
+ * The Windows named pipe the core serves for a socket path
20
+ * (`relay::transport::pipe_name`).
21
+ * @param socket - The socket path
22
+ * @returns `\\.\pipe\agent-relay-<16 hex>`
23
+ */
24
+ export declare function pipeName(socket: string): string;
25
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAIA,yFAAyF;AACzF,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,0EAA0E;AAC1E,eAAO,MAAM,eAAe,4BAA4B,CAAC;AACzD,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,QAAc,CAAC;AAC7C,kHAAkH;AAClH,eAAO,MAAM,eAAe,QAAmB,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,IAAI,GAAE,MAAqB,GAAG,MAAM,CAKxG;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAM/C"}
package/dist/paths.js ADDED
@@ -0,0 +1,42 @@
1
+ import { createHash } from 'node:crypto';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ /** The bridge version this client speaks (`crates/relay-node/src/relay/protocol.rs`). */
5
+ export const BRIDGE_VERSION = 2;
6
+ /** Moves the core's bridge socket, for the core and its clients alike. */
7
+ export const CORE_SOCKET_ENV = 'AGENT_RELAY_CORE_SOCKET';
8
+ /** The longest request line the core reads (`protocol.rs` `MAX_FRAME_BYTES`), without its newline. */
9
+ export const MAX_REQUEST_BYTES = 1024 * 1024;
10
+ /** The longest reply or event line this client buffers (`protocol.rs` `MAX_REPLY_BYTES`), without its newline. */
11
+ export const MAX_REPLY_BYTES = 16 * 1024 * 1024;
12
+ /**
13
+ * The core's bridge socket, resolved as the core resolves it: an absolute
14
+ * `AGENT_RELAY_CORE_SOCKET`, a relative one beside the default, else
15
+ * `<home>/.agentworkforce/desktop/core.sock`.
16
+ * @param env - Environment to read the override from (default `process.env`)
17
+ * @param home - The user's home directory (default `os.homedir()`)
18
+ * @returns Absolute socket path
19
+ */
20
+ export function coreSocketPath(env = process.env, home = os.homedir()) {
21
+ const fallback = path.join(home, '.agentworkforce', 'desktop', 'core.sock');
22
+ const configured = env[CORE_SOCKET_ENV]?.trim();
23
+ if (!configured)
24
+ return fallback;
25
+ return path.isAbsolute(configured) ? configured : path.join(path.dirname(fallback), configured);
26
+ }
27
+ /**
28
+ * The Windows named pipe the core serves for a socket path
29
+ * (`relay::transport::pipe_name`).
30
+ * @param socket - The socket path
31
+ * @returns `\\.\pipe\agent-relay-<16 hex>`
32
+ */
33
+ export function pipeName(socket) {
34
+ let key = socket.replace(/\//g, '\\').toLowerCase();
35
+ if (key.startsWith('\\\\?\\'))
36
+ key = key.slice(4);
37
+ while (key.length > 1 && key.endsWith('\\'))
38
+ key = key.slice(0, -1);
39
+ const hex = createHash('sha256').update(key, 'utf8').digest('hex').slice(0, 16);
40
+ return `\\\\.\\pipe\\agent-relay-${hex}`;
41
+ }
42
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"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AG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpE,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChF,OAAO,4BAA4B,GAAG,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Typed helpers for the service-caller identity and result-inbox methods.
3
+ *
4
+ * These methods are called only after {@link authenticate} has bound the
5
+ * bridge connection. They therefore never accept or send `caller_name` or
6
+ * `caller_secret`: the connection itself is the caller. The shapes mirror
7
+ * Agent Relay Desktop's `contract/service_callers.rs` schema-v2 contract.
8
+ */
9
+ import type { CallOptions, CoreClient } from './client.js';
10
+ import type { CallerFileDescriptor } from './auth.js';
11
+ export declare const SERVICE_CALLER_IDENTITY_METHOD = "spawn_callers.identity";
12
+ export declare const SERVICE_CALLER_INBOX_OPEN_METHOD = "spawn_callers.inbox.open";
13
+ export declare const SERVICE_CALLER_INBOX_NEXT_METHOD = "spawn_callers.inbox.next";
14
+ export declare const SERVICE_CALLER_INBOX_ACK_METHOD = "spawn_callers.inbox.ack";
15
+ export declare const SERVICE_CALLER_INBOX_FAIL_METHOD = "spawn_callers.inbox.fail";
16
+ export declare const SERVICE_CALLER_INBOX_CLOSE_METHOD = "spawn_callers.inbox.close";
17
+ export declare const SERVICE_CALLER_DISCONNECT_METHOD = "spawn_callers.disconnect";
18
+ /** The longest long-poll Desktop accepts for `inbox.next`. */
19
+ export declare const MAX_INBOX_NEXT_TIMEOUT_MS = 30000;
20
+ /** Extra transport time for Desktop to encode and return a completed poll. */
21
+ export declare const INBOX_NEXT_CALL_GRACE_MS = 5000;
22
+ export interface CallerPublisher {
23
+ id: string;
24
+ name: string;
25
+ }
26
+ export interface CallerNode {
27
+ id: string;
28
+ name: string;
29
+ }
30
+ export interface CallerIdentity {
31
+ publisher: CallerPublisher;
32
+ node: CallerNode;
33
+ base_url: string;
34
+ workspace_id: string;
35
+ relaycast_workspace_id: string;
36
+ }
37
+ /**
38
+ * Refuses when Desktop's bound identity is not the identity covered by the
39
+ * caller file. The local node is intentionally not compared: it is returned
40
+ * only by Desktop and selects the spawn target after this check.
41
+ * @param descriptor - The validated schema-v2 caller handoff.
42
+ * @param identity - The identity reported by the authenticated bridge connection.
43
+ * @returns Nothing when the publisher and workspace identities match exactly.
44
+ */
45
+ export declare function assertServiceCallerIdentity(descriptor: CallerFileDescriptor, identity: CallerIdentity): void;
46
+ export interface InboxOpened {
47
+ iterator_id: string;
48
+ }
49
+ export interface InboxSender {
50
+ id: string;
51
+ name: string;
52
+ }
53
+ export declare const INBOX_FAILURE_CODES: readonly ["result_too_large", "result_write_failed"];
54
+ export type InboxFailureCode = (typeof INBOX_FAILURE_CODES)[number];
55
+ export interface InboxFailure {
56
+ code: InboxFailureCode;
57
+ bytes: number;
58
+ limit: number;
59
+ }
60
+ export interface InboxDelivery {
61
+ item_id: string;
62
+ message_id: string;
63
+ sender: InboxSender;
64
+ text?: string;
65
+ failure?: InboxFailure;
66
+ invocation_id: string;
67
+ sent_at: string;
68
+ }
69
+ export interface InboxNext {
70
+ delivery: InboxDelivery | null;
71
+ }
72
+ export type InboxSettleAction = 'ack' | 'fail';
73
+ export type InboxSettleState = 'acked' | 'failed';
74
+ export interface InboxSettled {
75
+ item_id: string;
76
+ message_id: string;
77
+ action: InboxSettleAction;
78
+ state: InboxSettleState;
79
+ settled_at_ms: number;
80
+ }
81
+ /**
82
+ * Returns the publisher, local node and Relaycast scope of the bound caller.
83
+ * @param client - An authenticated service-caller bridge connection.
84
+ * @param options - Optional timeout and cancellation controls for the call.
85
+ * @returns The validated publisher, node, base URL and workspace identity.
86
+ */
87
+ export declare function serviceCallerIdentity(client: CoreClient, options?: CallOptions): Promise<CallerIdentity>;
88
+ /**
89
+ * Opens one inbox iterator, scoped durably to exactly one spawn invocation.
90
+ * @param client - An authenticated service-caller bridge connection.
91
+ * @param invocationId - The exact spawn invocation whose result is awaited.
92
+ * @param options - Optional timeout and cancellation controls for the call.
93
+ * @returns The validated identifier of the opened iterator.
94
+ */
95
+ export declare function serviceCallerInboxOpen(client: CoreClient, invocationId: string, options?: CallOptions): Promise<InboxOpened>;
96
+ /**
97
+ * Long-polls the next terminal delivery for an open iterator.
98
+ * @param client - An authenticated service-caller bridge connection.
99
+ * @param iteratorId - The exact iterator returned by {@link serviceCallerInboxOpen}.
100
+ * @param timeoutMs - The server-side long-poll duration, from zero through 30 seconds.
101
+ * @param options - Optional call timeout and cancellation controls.
102
+ * @returns The validated terminal delivery, or `null` when the poll elapsed.
103
+ */
104
+ export declare function serviceCallerInboxNext(client: CoreClient, iteratorId: string, timeoutMs?: number, options?: CallOptions): Promise<InboxNext>;
105
+ /**
106
+ * Acknowledges an item only after Relayflows durably journaled its result.
107
+ * @param client - An authenticated service-caller bridge connection.
108
+ * @param itemId - The exact inbox item whose result was journaled.
109
+ * @param options - Optional timeout and cancellation controls for the call.
110
+ * @returns The core's validated acknowledgement receipt.
111
+ */
112
+ export declare function serviceCallerInboxAck(client: CoreClient, itemId: string, options?: CallOptions): Promise<InboxSettled>;
113
+ /**
114
+ * Rejects an item whose result cannot be accepted into the Relayflows journal.
115
+ * @param client - An authenticated service-caller bridge connection.
116
+ * @param itemId - The exact inbox item whose result was rejected.
117
+ * @param options - Optional timeout and cancellation controls for the call.
118
+ * @returns The core's validated failure-settlement receipt.
119
+ */
120
+ export declare function serviceCallerInboxFail(client: CoreClient, itemId: string, options?: CallOptions): Promise<InboxSettled>;
121
+ /**
122
+ * Closes one iterator and releases any unsettled delivery lease it holds.
123
+ * @param client - An authenticated service-caller bridge connection.
124
+ * @param iteratorId - The exact iterator to close.
125
+ * @param options - Optional timeout and cancellation controls for the call.
126
+ * @returns A promise that resolves after the core confirms closure.
127
+ */
128
+ export declare function serviceCallerInboxClose(client: CoreClient, iteratorId: string, options?: CallOptions): Promise<void>;
129
+ /**
130
+ * Invalidates this connection's binding after every iterator is closed.
131
+ * @param client - An authenticated service-caller bridge connection.
132
+ * @param options - Optional timeout and cancellation controls for the call.
133
+ * @returns A promise that resolves after the core confirms disconnection.
134
+ */
135
+ export declare function serviceCallerDisconnect(client: CoreClient, options?: CallOptions): Promise<void>;
136
+ //# sourceMappingURL=service-callers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-callers.d.ts","sourceRoot":"","sources":["../src/service-callers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,eAAO,MAAM,8BAA8B,2BAA2B,CAAC;AACvE,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAC3E,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAC3E,eAAO,MAAM,+BAA+B,4BAA4B,CAAC;AACzE,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAC3E,eAAO,MAAM,iCAAiC,8BAA8B,CAAC;AAC7E,eAAO,MAAM,gCAAgC,6BAA6B,CAAC;AAE3E,8DAA8D;AAC9D,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAChD,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,Q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