@alfe.ai/claude-code-host 0.1.6 → 0.1.8
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/cli.cjs +1 -5
- package/dist/cli.js +1 -5
- package/dist/host-config.cjs +416 -116
- package/dist/host-config.js +407 -119
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +171 -65
- package/dist/index.d.ts +171 -65
- package/dist/index.js +2 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_host_config = require("./host-config.cjs");
|
|
3
3
|
exports.BRIDGE_ENV_VAR = require_host_config.BRIDGE_ENV_VAR;
|
|
4
|
+
exports.CLAUDE_PERMISSION_MODES = require_host_config.CLAUDE_PERMISSION_MODES;
|
|
4
5
|
exports.ClaudeCodeHost = require_host_config.ClaudeCodeHost;
|
|
5
6
|
exports.DEFAULT_ALLOWED_TOOLS = require_host_config.DEFAULT_ALLOWED_TOOLS;
|
|
6
7
|
exports.DEFAULT_PERMISSION_MODE = require_host_config.DEFAULT_PERMISSION_MODE;
|
|
7
8
|
exports.SCRUBBED_ANTHROPIC_ENV_VARS = require_host_config.SCRUBBED_ANTHROPIC_ENV_VARS;
|
|
8
9
|
exports.SessionDriver = require_host_config.SessionDriver;
|
|
10
|
+
exports.TERMINATION_GRACE_MS = require_host_config.TERMINATION_GRACE_MS;
|
|
9
11
|
exports.TURN_TIMEOUT_MS = require_host_config.TURN_TIMEOUT_MS;
|
|
10
12
|
exports.WARM_STREAMING_SUPPORTED = require_host_config.WARM_STREAMING_SUPPORTED;
|
|
11
13
|
exports.addMessage = require_host_config.addMessage;
|
package/dist/index.d.cts
CHANGED
|
@@ -29,26 +29,32 @@ declare class AgentApiTransport {
|
|
|
29
29
|
* `Content-Type: application/json` and parses a `{ data: T }` envelope,
|
|
30
30
|
* neither of which fits a raw-audio flow (voice TTS/STT), so those go
|
|
31
31
|
* through this instead. Auth (Bearer), the request budget, and the single
|
|
32
|
-
* retry on transient 5xx / network errors
|
|
33
|
-
* `request()`.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* retry policy on transient 5xx / network errors is kept in sync with
|
|
33
|
+
* `request()`. Safe read methods retry once by default; mutation methods do
|
|
34
|
+
* not, because a response can be lost after a handler or provider call has
|
|
35
|
+
* already succeeded.
|
|
36
36
|
*/
|
|
37
37
|
rawRequest(path: string, init: {
|
|
38
38
|
method: string;
|
|
39
39
|
headers: Headers;
|
|
40
40
|
body?: BodyInit | Uint8Array;
|
|
41
|
+
}, extra?: {
|
|
42
|
+
retry?: boolean;
|
|
41
43
|
}): Promise<Response>;
|
|
42
44
|
/**
|
|
43
45
|
* @param extra.timeoutMs Per-request abort timeout (default REQUEST_TIMEOUT_MS).
|
|
44
46
|
* Long endpoints (image generation) pass a larger value so the gateway's
|
|
45
47
|
* own timeout wins with a readable status instead of a client-side abort.
|
|
46
|
-
* @param extra.retry Whether to retry once on transient failures
|
|
47
|
-
*
|
|
48
|
+
* @param extra.retry Whether to retry once on transient failures. Safe reads
|
|
49
|
+
* (GET/HEAD/OPTIONS) default to true; mutations default to false. Set true
|
|
50
|
+
* only when the endpoint's server-side contract is explicitly idempotent.
|
|
51
|
+
* @param extra.signal Optional caller cancellation combined with the client's
|
|
52
|
+
* own timeout budget. Aborting either signal cancels the request.
|
|
48
53
|
*/
|
|
49
54
|
request<T>(path: string, options?: RequestInit, extra?: {
|
|
50
55
|
timeoutMs?: number;
|
|
51
56
|
retry?: boolean;
|
|
57
|
+
signal?: AbortSignal;
|
|
52
58
|
}): Promise<T>;
|
|
53
59
|
}
|
|
54
60
|
/**
|
|
@@ -64,7 +70,7 @@ declare class ApiBase {
|
|
|
64
70
|
//# sourceMappingURL=transport.d.ts.map
|
|
65
71
|
//#endregion
|
|
66
72
|
//#region src/domains/workspace.d.ts
|
|
67
|
-
/** Response of GET /
|
|
73
|
+
/** Response of GET /agent/workspace (services/agents). */
|
|
68
74
|
interface AgentWorkspaceInfo {
|
|
69
75
|
templateKey?: string;
|
|
70
76
|
defaultModel?: string;
|
|
@@ -92,7 +98,7 @@ interface AgentWorkspaceInfo {
|
|
|
92
98
|
}
|
|
93
99
|
declare class WorkspaceApi extends ApiBase {
|
|
94
100
|
/**
|
|
95
|
-
* GET /
|
|
101
|
+
* GET /agent/workspace — workspace config for the authenticated agent
|
|
96
102
|
* (template assignment, default model, org roster).
|
|
97
103
|
*/
|
|
98
104
|
getWorkspace(): Promise<AgentWorkspaceInfo>;
|
|
@@ -235,6 +241,8 @@ declare class SyncApi extends ApiBase {
|
|
|
235
241
|
sharedListFiles(args: {
|
|
236
242
|
scope: "org" | "team" | "project";
|
|
237
243
|
scopeId: string;
|
|
244
|
+
limit?: number;
|
|
245
|
+
cursor?: string;
|
|
238
246
|
}): Promise<{
|
|
239
247
|
files: SharedFileEntry[];
|
|
240
248
|
nextCursor: string | null;
|
|
@@ -394,7 +402,9 @@ declare class KnowledgeApi extends ApiBase {
|
|
|
394
402
|
* from `services/org`, then fetches the bytes directly from S3 (the one
|
|
395
403
|
* legitimate raw fetch in a plugin — same pattern as sync).
|
|
396
404
|
*/
|
|
397
|
-
readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string
|
|
405
|
+
readScopeDoc(scopeType: KnowledgeScopeType, scopeId: string, filePath: string, opts?: {
|
|
406
|
+
maxBytes?: number;
|
|
407
|
+
}): Promise<{
|
|
398
408
|
filePath: string;
|
|
399
409
|
text: string;
|
|
400
410
|
}>;
|
|
@@ -433,15 +443,11 @@ interface MobileAvailableNumber {
|
|
|
433
443
|
}
|
|
434
444
|
/** Approved WhatsApp content template from GET /mobile/whatsapp/templates. */
|
|
435
445
|
interface WhatsAppTemplate {
|
|
436
|
-
|
|
437
|
-
|
|
446
|
+
contentSid: string;
|
|
447
|
+
name: string;
|
|
438
448
|
language: string;
|
|
439
449
|
body: string;
|
|
440
450
|
variables: Record<string, string>;
|
|
441
|
-
dateCreated: string;
|
|
442
|
-
dateUpdated: string;
|
|
443
|
-
approvalStatus?: string;
|
|
444
|
-
rejectionReason?: string;
|
|
445
451
|
category?: string;
|
|
446
452
|
}
|
|
447
453
|
declare class MobileApi extends ApiBase {
|
|
@@ -689,15 +695,22 @@ declare class SearchApi extends ApiBase {
|
|
|
689
695
|
offset?: number;
|
|
690
696
|
country?: string;
|
|
691
697
|
freshness?: string;
|
|
698
|
+
}, options?: {
|
|
699
|
+
signal?: AbortSignal;
|
|
692
700
|
}): Promise<unknown>;
|
|
693
701
|
searchImages(params: {
|
|
694
702
|
query: string;
|
|
695
703
|
count?: number;
|
|
704
|
+
}, options?: {
|
|
705
|
+
signal?: AbortSignal;
|
|
696
706
|
}): Promise<unknown>;
|
|
697
707
|
searchNews(params: {
|
|
698
708
|
query: string;
|
|
699
709
|
count?: number;
|
|
710
|
+
offset?: number;
|
|
700
711
|
freshness?: string;
|
|
712
|
+
}, options?: {
|
|
713
|
+
signal?: AbortSignal;
|
|
701
714
|
}): Promise<unknown>;
|
|
702
715
|
/** Search news across the selected provider's corpus. → POST /agent/news/search */
|
|
703
716
|
newsSearch(params: {
|
|
@@ -721,6 +734,48 @@ declare class SearchApi extends ApiBase {
|
|
|
721
734
|
}
|
|
722
735
|
//# sourceMappingURL=search.d.ts.map
|
|
723
736
|
//#endregion
|
|
737
|
+
//#region src/domains/webhooks.d.ts
|
|
738
|
+
interface AgentWebhook {
|
|
739
|
+
webhookId: string;
|
|
740
|
+
tenantId: string;
|
|
741
|
+
agentId: string;
|
|
742
|
+
name: string;
|
|
743
|
+
provider: string;
|
|
744
|
+
active: boolean;
|
|
745
|
+
createdBy: string;
|
|
746
|
+
createdAt: string;
|
|
747
|
+
updatedAt: string;
|
|
748
|
+
}
|
|
749
|
+
interface CreatedAgentWebhook extends AgentWebhook {
|
|
750
|
+
url: string;
|
|
751
|
+
signingSecret: string;
|
|
752
|
+
}
|
|
753
|
+
interface AgentWebhookDelivery {
|
|
754
|
+
deliveryId: string;
|
|
755
|
+
webhookId: string;
|
|
756
|
+
status: string;
|
|
757
|
+
attempts: number;
|
|
758
|
+
createdAt: string;
|
|
759
|
+
deliveredAt?: string;
|
|
760
|
+
}
|
|
761
|
+
declare class WebhooksApi extends ApiBase {
|
|
762
|
+
createWebhook(args: {
|
|
763
|
+
name: string;
|
|
764
|
+
provider?: "generic" | "github" | "stripe" | "slack";
|
|
765
|
+
}): Promise<CreatedAgentWebhook>;
|
|
766
|
+
listWebhooks(): Promise<AgentWebhook[]>;
|
|
767
|
+
deleteWebhook(webhookId: string): Promise<{
|
|
768
|
+
webhookId: string;
|
|
769
|
+
active: false;
|
|
770
|
+
}>;
|
|
771
|
+
rotateWebhookSecret(webhookId: string): Promise<{
|
|
772
|
+
webhookId: string;
|
|
773
|
+
signingSecret: string;
|
|
774
|
+
}>;
|
|
775
|
+
listWebhookDeliveries(webhookId: string): Promise<AgentWebhookDelivery[]>;
|
|
776
|
+
}
|
|
777
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
778
|
+
//#endregion
|
|
724
779
|
//#region src/domains/chat.d.ts
|
|
725
780
|
declare class ChatApi extends ApiBase {
|
|
726
781
|
presignAttachments(files: {
|
|
@@ -857,8 +912,9 @@ declare class ConnectCredentialsApi extends ApiBase {
|
|
|
857
912
|
* selector arg (e.g. `xeroTenantId`) on every credential-touching tool
|
|
858
913
|
* and look up the matching account by that selector at dispatch time.
|
|
859
914
|
*
|
|
860
|
-
*
|
|
861
|
-
*
|
|
915
|
+
* `xeroTenantId` is the model-facing organisation selector. The separate
|
|
916
|
+
* `accountIdentifier` is the Connect persistence key used for refresh and
|
|
917
|
+
* may be an email; never substitute one for the other.
|
|
862
918
|
*/
|
|
863
919
|
getXeroAccounts(): Promise<{
|
|
864
920
|
accounts: {
|
|
@@ -876,12 +932,12 @@ declare class ConnectCredentialsApi extends ApiBase {
|
|
|
876
932
|
expiresAt: string;
|
|
877
933
|
}>;
|
|
878
934
|
/**
|
|
879
|
-
*
|
|
880
|
-
* (
|
|
881
|
-
* the
|
|
882
|
-
*
|
|
935
|
+
* Refresh a specific Xero Connection by its exact `accountIdentifier` from
|
|
936
|
+
* `getXeroAccounts()`. Do not substitute `xeroTenantId`: current Xero OAuth
|
|
937
|
+
* rows may use the account email as their persistence key even when a sole
|
|
938
|
+
* organisation tenant ID is available in provider metadata.
|
|
883
939
|
*/
|
|
884
|
-
refreshXeroAccountToken(
|
|
940
|
+
refreshXeroAccountToken(accountIdentifier: string): Promise<{
|
|
885
941
|
accessToken: string;
|
|
886
942
|
accessTokenExpiresAt: string;
|
|
887
943
|
expiresAt: string;
|
|
@@ -1036,6 +1092,21 @@ declare class ConnectCredentialsApi extends ApiBase {
|
|
|
1036
1092
|
accessToken: string;
|
|
1037
1093
|
expiresAt: string;
|
|
1038
1094
|
}>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Pattern A: refresh one MYOB Connection by its stable
|
|
1097
|
+
* `accountIdentifier` (the MYOB business id returned by
|
|
1098
|
+
* `getMYOBAccounts()`).
|
|
1099
|
+
*
|
|
1100
|
+
* MYOB refresh tokens belong to individual Connection rows. A
|
|
1101
|
+
* multi-business client must use this method instead of refreshing the
|
|
1102
|
+
* primary Connection and copying that access token into every cached
|
|
1103
|
+
* business client.
|
|
1104
|
+
*/
|
|
1105
|
+
refreshMYOBAccountToken(accountIdentifier: string): Promise<{
|
|
1106
|
+
accessToken: string;
|
|
1107
|
+
accessTokenExpiresAt: string;
|
|
1108
|
+
expiresAt: string;
|
|
1109
|
+
}>;
|
|
1039
1110
|
/**
|
|
1040
1111
|
* @deprecated Returns a single primary credential blob. Use
|
|
1041
1112
|
* `getSalesforceAccounts()` for the multi-account shape required by
|
|
@@ -1098,9 +1169,6 @@ declare class ConnectCredentialsApi extends ApiBase {
|
|
|
1098
1169
|
connectedAt: string;
|
|
1099
1170
|
accessToken: string;
|
|
1100
1171
|
accessTokenExpiresAt: string;
|
|
1101
|
-
refreshToken: string;
|
|
1102
|
-
clientId: string;
|
|
1103
|
-
clientSecret: string;
|
|
1104
1172
|
email: string;
|
|
1105
1173
|
microsoftTenantId: string;
|
|
1106
1174
|
workspaceDomain: string;
|
|
@@ -1206,10 +1274,41 @@ declare class ConnectCredentialsApi extends ApiBase {
|
|
|
1206
1274
|
brokerName?: string;
|
|
1207
1275
|
accountNumber?: string;
|
|
1208
1276
|
accessToken: string;
|
|
1277
|
+
/**
|
|
1278
|
+
* The stable per-grant Connection key (`ctid:<userId>`) this account
|
|
1279
|
+
* belongs to. Every trading account under one cTrader login shares one
|
|
1280
|
+
* grant (one OAuth token), so this is the identifier the MCP server
|
|
1281
|
+
* passes to `refreshCTraderAccount()` to rotate the token for the whole
|
|
1282
|
+
* grant on a `CH_ACCESS_TOKEN_INVALID` expiry. Empty string when the
|
|
1283
|
+
* server did not supply one (legacy rows) — such an account can still
|
|
1284
|
+
* trade with its current token but cannot self-refresh.
|
|
1285
|
+
*/
|
|
1286
|
+
accountIdentifier: string;
|
|
1209
1287
|
}[];
|
|
1210
1288
|
clientId: string;
|
|
1211
1289
|
clientSecret: string;
|
|
1212
1290
|
}>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Pattern A: refresh a specific cTrader grant by its stable
|
|
1293
|
+
* `accountIdentifier` (`ctid:<userId>` from `getCTraderAccounts()`).
|
|
1294
|
+
*
|
|
1295
|
+
* cTrader access tokens live ~30 days; the `getCTraderAccounts()` /
|
|
1296
|
+
* credentials reads serve the STORED token without refreshing, so refresh is
|
|
1297
|
+
* the consumer's job. `@alfe.ai/ctrader-mcp` calls this when the cTrader Open
|
|
1298
|
+
* API rejects an account-auth with `CH_ACCESS_TOKEN_INVALID`, then re-runs
|
|
1299
|
+
* the socket handshake with the returned `accessToken`.
|
|
1300
|
+
*
|
|
1301
|
+
* Refreshing one grant rotates the single OAuth token that covers EVERY
|
|
1302
|
+
* trading account under that login. cTrader's refresh token itself does not
|
|
1303
|
+
* expire but may rotate on refresh (`rotatesRefreshToken: true`); connect
|
|
1304
|
+
* persists the rotated refresh token server-side, so the caller only needs
|
|
1305
|
+
* the new `accessToken`. Mirrors `refreshXeroAccountToken`.
|
|
1306
|
+
*/
|
|
1307
|
+
refreshCTraderAccount(accountIdentifier: string): Promise<{
|
|
1308
|
+
accessToken: string;
|
|
1309
|
+
accessTokenExpiresAt: string;
|
|
1310
|
+
expiresAt: string;
|
|
1311
|
+
}>;
|
|
1213
1312
|
/**
|
|
1214
1313
|
* @deprecated Returns a single primary credential blob. Use
|
|
1215
1314
|
* `getShopifyAccounts()` for the multi-account shape required by Pattern A
|
|
@@ -1374,59 +1473,35 @@ declare class IdentityApi extends ApiBase {
|
|
|
1374
1473
|
}>;
|
|
1375
1474
|
mergeIdentities(survivorId: string, args: {
|
|
1376
1475
|
mergedId: string;
|
|
1377
|
-
changedBy: {
|
|
1378
|
-
type: string;
|
|
1379
|
-
id: string;
|
|
1380
|
-
name?: string;
|
|
1381
|
-
};
|
|
1382
1476
|
}): Promise<{
|
|
1383
1477
|
ok: boolean;
|
|
1384
1478
|
error?: string;
|
|
1385
1479
|
}>;
|
|
1386
|
-
unmergeIdentity(identityId: string
|
|
1387
|
-
changedBy: {
|
|
1388
|
-
type: string;
|
|
1389
|
-
id: string;
|
|
1390
|
-
name?: string;
|
|
1391
|
-
};
|
|
1392
|
-
}): Promise<{
|
|
1480
|
+
unmergeIdentity(identityId: string): Promise<{
|
|
1393
1481
|
ok: boolean;
|
|
1394
1482
|
error?: string;
|
|
1395
1483
|
}>;
|
|
1396
1484
|
addIdentityNote(identityId: string, args: {
|
|
1397
1485
|
content: string;
|
|
1398
1486
|
category?: string;
|
|
1399
|
-
changedBy: {
|
|
1400
|
-
type: string;
|
|
1401
|
-
id: string;
|
|
1402
|
-
name?: string;
|
|
1403
|
-
};
|
|
1404
1487
|
}): Promise<{
|
|
1405
1488
|
noteId: string | null;
|
|
1406
1489
|
}>;
|
|
1407
1490
|
tagIdentity(identityId: string, args: {
|
|
1408
1491
|
tag: string;
|
|
1409
1492
|
action: "add" | "remove";
|
|
1410
|
-
changedBy: {
|
|
1411
|
-
type: string;
|
|
1412
|
-
id: string;
|
|
1413
|
-
name?: string;
|
|
1414
|
-
};
|
|
1415
1493
|
}): Promise<{
|
|
1416
1494
|
ok: boolean;
|
|
1417
1495
|
}>;
|
|
1418
1496
|
getIdentityChangelog(identityId: string, args?: {
|
|
1419
1497
|
limit?: number;
|
|
1498
|
+
cursor?: string;
|
|
1420
1499
|
}): Promise<{
|
|
1421
1500
|
entries: unknown[];
|
|
1501
|
+
cursor: string | null;
|
|
1422
1502
|
}>;
|
|
1423
1503
|
rollbackIdentity(identityId: string, args: {
|
|
1424
1504
|
targetVersion: number;
|
|
1425
|
-
changedBy: {
|
|
1426
|
-
type: string;
|
|
1427
|
-
id: string;
|
|
1428
|
-
name?: string;
|
|
1429
|
-
};
|
|
1430
1505
|
}): Promise<{
|
|
1431
1506
|
ok: boolean;
|
|
1432
1507
|
entry?: unknown;
|
|
@@ -1465,7 +1540,7 @@ declare class IdentityApi extends ApiBase {
|
|
|
1465
1540
|
verified: boolean;
|
|
1466
1541
|
identityId?: string;
|
|
1467
1542
|
/** Phase 2: how the confirm resolved — Scenario A vs B. */
|
|
1468
|
-
action?: "merged" | "contact_verified";
|
|
1543
|
+
action?: "merged" | "contact_verified" | "already_confirmed";
|
|
1469
1544
|
error?: string;
|
|
1470
1545
|
}>;
|
|
1471
1546
|
/**
|
|
@@ -1597,8 +1672,21 @@ declare class MemoryApi extends ApiBase {
|
|
|
1597
1672
|
messageCount: number;
|
|
1598
1673
|
}>;
|
|
1599
1674
|
memoryLoadContext(tier?: number, topicHint?: string): Promise<{
|
|
1675
|
+
tier: number;
|
|
1676
|
+
facts: {
|
|
1677
|
+
subject: string;
|
|
1678
|
+
predicate: string;
|
|
1679
|
+
object: string;
|
|
1680
|
+
since: string;
|
|
1681
|
+
}[];
|
|
1682
|
+
memories: {
|
|
1683
|
+
text: string;
|
|
1684
|
+
topic: string;
|
|
1685
|
+
subtopic: string;
|
|
1686
|
+
score: number;
|
|
1687
|
+
}[];
|
|
1688
|
+
tokenEstimate: number;
|
|
1600
1689
|
formatted: string;
|
|
1601
|
-
[key: string]: unknown;
|
|
1602
1690
|
}>;
|
|
1603
1691
|
memoryLookupEntity(subject: string): Promise<{
|
|
1604
1692
|
subject: string;
|
|
@@ -1830,7 +1918,7 @@ declare class TeamsApi extends ApiBase {
|
|
|
1830
1918
|
|
|
1831
1919
|
//#endregion
|
|
1832
1920
|
//#region src/index.d.ts
|
|
1833
|
-
interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi {}
|
|
1921
|
+
interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi, WebhooksApi {}
|
|
1834
1922
|
declare class AgentApiClient extends ApiBase {
|
|
1835
1923
|
constructor(config: AgentApiClientConfig);
|
|
1836
1924
|
}
|
|
@@ -1850,7 +1938,7 @@ interface ChatServiceClientOptions {
|
|
|
1850
1938
|
/** Agent API key for Bearer auth */
|
|
1851
1939
|
apiKey: string;
|
|
1852
1940
|
/** Called when the chat service sends an RPC request */
|
|
1853
|
-
onRequest: (request: RpcRequest) => void
|
|
1941
|
+
onRequest: (request: RpcRequest) => void | Promise<void>;
|
|
1854
1942
|
/** Called when connection state changes */
|
|
1855
1943
|
onConnectionChange?: (connected: boolean) => void;
|
|
1856
1944
|
/** Optional logger (defaults to console) */
|
|
@@ -1872,12 +1960,12 @@ interface Logger {
|
|
|
1872
1960
|
}
|
|
1873
1961
|
//#endregion
|
|
1874
1962
|
//#region src/client.d.ts
|
|
1875
|
-
|
|
1876
1963
|
declare class ChatServiceClient {
|
|
1877
1964
|
private readonly options;
|
|
1878
1965
|
private ws;
|
|
1879
1966
|
private stopped;
|
|
1880
1967
|
private connected;
|
|
1968
|
+
private connectionGeneration;
|
|
1881
1969
|
private retryCount;
|
|
1882
1970
|
private retryTimer;
|
|
1883
1971
|
private heartbeatTimer;
|
|
@@ -1886,7 +1974,7 @@ declare class ChatServiceClient {
|
|
|
1886
1974
|
private pendingRequests;
|
|
1887
1975
|
private requestCounter;
|
|
1888
1976
|
private messageQueue;
|
|
1889
|
-
private
|
|
1977
|
+
private queuedBytes;
|
|
1890
1978
|
constructor(options: ChatServiceClientOptions);
|
|
1891
1979
|
get isConnected(): boolean;
|
|
1892
1980
|
/** Start connecting to the chat service. */
|
|
@@ -1907,8 +1995,13 @@ declare class ChatServiceClient {
|
|
|
1907
1995
|
*/
|
|
1908
1996
|
sendRequest(method: string, params: Record<string, unknown>, timeoutMs?: number): Promise<Record<string, unknown>>;
|
|
1909
1997
|
private flushMessageQueue;
|
|
1998
|
+
private enqueueMessage;
|
|
1910
1999
|
private flushPendingRequests;
|
|
2000
|
+
private rejectPendingRequest;
|
|
1911
2001
|
private doConnect;
|
|
2002
|
+
private isCurrentSocket;
|
|
2003
|
+
private setConnected;
|
|
2004
|
+
private notifyConnectionChange;
|
|
1912
2005
|
private handleMessage;
|
|
1913
2006
|
private scheduleReconnect;
|
|
1914
2007
|
/**
|
|
@@ -2080,14 +2173,20 @@ declare const WARM_STREAMING_SUPPORTED = false;
|
|
|
2080
2173
|
* posture). An inbound chat message could try to induce a destructive shell
|
|
2081
2174
|
* command, and these turns run unattended on the user's machine. We therefore
|
|
2082
2175
|
* pass an explicit allow-list of read/analysis/edit tools and DENY Bash by
|
|
2083
|
-
* default, and use `--permission-mode
|
|
2176
|
+
* default, and use `--permission-mode dontAsk` (NEVER `bypassPermissions` /
|
|
2084
2177
|
* `--dangerously-skip-permissions`). See DEVELOPING.md → "Tool-permission
|
|
2085
2178
|
* posture". Bash is intentionally absent — a bridged turn cannot run arbitrary
|
|
2086
2179
|
* shell. Callers that want a wider set pass `allowedTools` explicitly.
|
|
2087
2180
|
*/
|
|
2088
2181
|
declare const DEFAULT_ALLOWED_TOOLS: readonly ["Read", "Grep", "Glob", "LS", "Edit", "Write", "WebFetch", "WebSearch", "Task", "TodoWrite"];
|
|
2089
|
-
|
|
2090
|
-
|
|
2182
|
+
declare const CLAUDE_PERMISSION_MODES: readonly ["acceptEdits", "auto", "manual", "dontAsk", "plan"];
|
|
2183
|
+
type ClaudePermissionMode = (typeof CLAUDE_PERMISSION_MODES)[number];
|
|
2184
|
+
/**
|
|
2185
|
+
* Headless-safe permission posture supported by current Claude CLI releases.
|
|
2186
|
+
* Allow-listed tools run; any permission prompt the bridge cannot answer is
|
|
2187
|
+
* denied. `bypassPermissions` is deliberately not representable.
|
|
2188
|
+
*/
|
|
2189
|
+
declare const DEFAULT_PERMISSION_MODE: ClaudePermissionMode;
|
|
2091
2190
|
/** How a turn ended, surfaced to the host so it can settle / persist. */
|
|
2092
2191
|
interface DriverTurnResult {
|
|
2093
2192
|
/** The claude session id observed on the `system:init` event (for --resume). */
|
|
@@ -2119,7 +2218,7 @@ interface RunTurnParams {
|
|
|
2119
2218
|
/** Tool allow-list (defaults to DEFAULT_ALLOWED_TOOLS). */
|
|
2120
2219
|
allowedTools?: readonly string[];
|
|
2121
2220
|
/** Permission mode (defaults to DEFAULT_PERMISSION_MODE — never bypass). */
|
|
2122
|
-
permissionMode?:
|
|
2221
|
+
permissionMode?: ClaudePermissionMode;
|
|
2123
2222
|
/** Per-emission callback so the host can stream deltas/activity live. */
|
|
2124
2223
|
onEmission: (emission: MapperEmission) => void;
|
|
2125
2224
|
/** Wall-clock override for the mapper (tests). Defaults to Date.now. */
|
|
@@ -2134,6 +2233,8 @@ interface RunTurnParams {
|
|
|
2134
2233
|
* cap, but the late settle is harmlessly no-op'd by the chat service.
|
|
2135
2234
|
*/
|
|
2136
2235
|
declare const TURN_TIMEOUT_MS = 300000;
|
|
2236
|
+
/** Grace after SIGINT before SIGKILL + local settlement. Keeps E2 under 305s. */
|
|
2237
|
+
declare const TERMINATION_GRACE_MS = 2000;
|
|
2137
2238
|
/**
|
|
2138
2239
|
* Spawns and drives `claude` subprocesses. Tracks a SINGLE in-flight child, so
|
|
2139
2240
|
* the host creates ONE driver PER TURN (`ClaudeCodeHost.makeDriver`) — a driver
|
|
@@ -2142,6 +2243,7 @@ declare const TURN_TIMEOUT_MS = 300000;
|
|
|
2142
2243
|
*/
|
|
2143
2244
|
declare class SessionDriver {
|
|
2144
2245
|
private child;
|
|
2246
|
+
private abortCurrent;
|
|
2145
2247
|
private readonly bin;
|
|
2146
2248
|
private readonly baseEnv;
|
|
2147
2249
|
private readonly log;
|
|
@@ -2215,6 +2317,9 @@ declare class ClaudeCodeHost {
|
|
|
2215
2317
|
private readonly seenIdempotencyKeys;
|
|
2216
2318
|
/** RPC sessionKey → resolved SessionDriver so chat.abort can SIGINT the child. */
|
|
2217
2319
|
private activeDriverBySession;
|
|
2320
|
+
private claudeSessionSave;
|
|
2321
|
+
private stopping;
|
|
2322
|
+
private stopPromise;
|
|
2218
2323
|
constructor(cfg: ClaudeCodeHostConfig, deps?: {
|
|
2219
2324
|
/** Per-turn driver factory (test seam). Called once per turn. */
|
|
2220
2325
|
makeDriver?: () => SessionDriver;
|
|
@@ -2223,8 +2328,8 @@ declare class ClaudeCodeHost {
|
|
|
2223
2328
|
});
|
|
2224
2329
|
/** Start the chat WS. Non-blocking — the client reconnects internally. */
|
|
2225
2330
|
start(): Promise<void>;
|
|
2226
|
-
/** Stop
|
|
2227
|
-
stop(): void
|
|
2331
|
+
/** Stop admission, abort owned children, and give active turns time to settle. */
|
|
2332
|
+
stop(): Promise<void>;
|
|
2228
2333
|
/**
|
|
2229
2334
|
* Inbound RPC dispatch. Invoked by the chat client's `onRequest` in
|
|
2230
2335
|
* production; also the test seam (drive `agent`/`chat.abort`/… directly).
|
|
@@ -2246,6 +2351,7 @@ declare class ClaudeCodeHost {
|
|
|
2246
2351
|
private ensureSession;
|
|
2247
2352
|
private loadClaudeSessionIds;
|
|
2248
2353
|
private saveClaudeSessionIds;
|
|
2354
|
+
private rememberClaudeSessionId;
|
|
2249
2355
|
private pruneIdempotency;
|
|
2250
2356
|
}
|
|
2251
2357
|
/** Strip the `agent:{agentId}:` prefix from a full server session key. */
|
|
@@ -2404,4 +2510,4 @@ declare function listSessions(filters?: {
|
|
|
2404
2510
|
*/
|
|
2405
2511
|
declare function resolveHostConfig(): ClaudeCodeHostConfig;
|
|
2406
2512
|
//#endregion
|
|
2407
|
-
export { type ActivityEmission, BRIDGE_ENV_VAR, type ChatActivityRecord, type ChatMessage, ClaudeCodeHost, type ClaudeCodeHostConfig, DEFAULT_ALLOWED_TOOLS, DEFAULT_PERMISSION_MODE, type DriverTurnResult, type EndEmission, type MapperEmission, type MapperState, type RunTurnParams, SCRUBBED_ANTHROPIC_ENV_VARS, type SessionData, SessionDriver, type SessionSummary, TURN_TIMEOUT_MS, type TextEmission, type ThinkingActivity, type ToolActivity, WARM_STREAMING_SUPPORTED, addMessage, appendActivity, buildChildEnv, collectTurnActivityRecords, createMapperState, createSession, getSession, listSessions, mapStreamEvent, mapStreamEvents, resolveHostConfig, saveSession, stripAgentPrefix };
|
|
2513
|
+
export { type ActivityEmission, BRIDGE_ENV_VAR, CLAUDE_PERMISSION_MODES, type ChatActivityRecord, type ChatMessage, ClaudeCodeHost, type ClaudeCodeHostConfig, type ClaudePermissionMode, DEFAULT_ALLOWED_TOOLS, DEFAULT_PERMISSION_MODE, type DriverTurnResult, type EndEmission, type MapperEmission, type MapperState, type RunTurnParams, SCRUBBED_ANTHROPIC_ENV_VARS, type SessionData, SessionDriver, type SessionSummary, TERMINATION_GRACE_MS, TURN_TIMEOUT_MS, type TextEmission, type ThinkingActivity, type ToolActivity, WARM_STREAMING_SUPPORTED, addMessage, appendActivity, buildChildEnv, collectTurnActivityRecords, createMapperState, createSession, getSession, listSessions, mapStreamEvent, mapStreamEvents, resolveHostConfig, saveSession, stripAgentPrefix };
|