@alfe.ai/claude-code-host 0.1.6 → 0.1.7
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 +140 -65
- package/dist/index.d.ts +140 -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;
|
|
@@ -1374,59 +1442,35 @@ declare class IdentityApi extends ApiBase {
|
|
|
1374
1442
|
}>;
|
|
1375
1443
|
mergeIdentities(survivorId: string, args: {
|
|
1376
1444
|
mergedId: string;
|
|
1377
|
-
changedBy: {
|
|
1378
|
-
type: string;
|
|
1379
|
-
id: string;
|
|
1380
|
-
name?: string;
|
|
1381
|
-
};
|
|
1382
1445
|
}): Promise<{
|
|
1383
1446
|
ok: boolean;
|
|
1384
1447
|
error?: string;
|
|
1385
1448
|
}>;
|
|
1386
|
-
unmergeIdentity(identityId: string
|
|
1387
|
-
changedBy: {
|
|
1388
|
-
type: string;
|
|
1389
|
-
id: string;
|
|
1390
|
-
name?: string;
|
|
1391
|
-
};
|
|
1392
|
-
}): Promise<{
|
|
1449
|
+
unmergeIdentity(identityId: string): Promise<{
|
|
1393
1450
|
ok: boolean;
|
|
1394
1451
|
error?: string;
|
|
1395
1452
|
}>;
|
|
1396
1453
|
addIdentityNote(identityId: string, args: {
|
|
1397
1454
|
content: string;
|
|
1398
1455
|
category?: string;
|
|
1399
|
-
changedBy: {
|
|
1400
|
-
type: string;
|
|
1401
|
-
id: string;
|
|
1402
|
-
name?: string;
|
|
1403
|
-
};
|
|
1404
1456
|
}): Promise<{
|
|
1405
1457
|
noteId: string | null;
|
|
1406
1458
|
}>;
|
|
1407
1459
|
tagIdentity(identityId: string, args: {
|
|
1408
1460
|
tag: string;
|
|
1409
1461
|
action: "add" | "remove";
|
|
1410
|
-
changedBy: {
|
|
1411
|
-
type: string;
|
|
1412
|
-
id: string;
|
|
1413
|
-
name?: string;
|
|
1414
|
-
};
|
|
1415
1462
|
}): Promise<{
|
|
1416
1463
|
ok: boolean;
|
|
1417
1464
|
}>;
|
|
1418
1465
|
getIdentityChangelog(identityId: string, args?: {
|
|
1419
1466
|
limit?: number;
|
|
1467
|
+
cursor?: string;
|
|
1420
1468
|
}): Promise<{
|
|
1421
1469
|
entries: unknown[];
|
|
1470
|
+
cursor: string | null;
|
|
1422
1471
|
}>;
|
|
1423
1472
|
rollbackIdentity(identityId: string, args: {
|
|
1424
1473
|
targetVersion: number;
|
|
1425
|
-
changedBy: {
|
|
1426
|
-
type: string;
|
|
1427
|
-
id: string;
|
|
1428
|
-
name?: string;
|
|
1429
|
-
};
|
|
1430
1474
|
}): Promise<{
|
|
1431
1475
|
ok: boolean;
|
|
1432
1476
|
entry?: unknown;
|
|
@@ -1465,7 +1509,7 @@ declare class IdentityApi extends ApiBase {
|
|
|
1465
1509
|
verified: boolean;
|
|
1466
1510
|
identityId?: string;
|
|
1467
1511
|
/** Phase 2: how the confirm resolved — Scenario A vs B. */
|
|
1468
|
-
action?: "merged" | "contact_verified";
|
|
1512
|
+
action?: "merged" | "contact_verified" | "already_confirmed";
|
|
1469
1513
|
error?: string;
|
|
1470
1514
|
}>;
|
|
1471
1515
|
/**
|
|
@@ -1597,8 +1641,21 @@ declare class MemoryApi extends ApiBase {
|
|
|
1597
1641
|
messageCount: number;
|
|
1598
1642
|
}>;
|
|
1599
1643
|
memoryLoadContext(tier?: number, topicHint?: string): Promise<{
|
|
1644
|
+
tier: number;
|
|
1645
|
+
facts: {
|
|
1646
|
+
subject: string;
|
|
1647
|
+
predicate: string;
|
|
1648
|
+
object: string;
|
|
1649
|
+
since: string;
|
|
1650
|
+
}[];
|
|
1651
|
+
memories: {
|
|
1652
|
+
text: string;
|
|
1653
|
+
topic: string;
|
|
1654
|
+
subtopic: string;
|
|
1655
|
+
score: number;
|
|
1656
|
+
}[];
|
|
1657
|
+
tokenEstimate: number;
|
|
1600
1658
|
formatted: string;
|
|
1601
|
-
[key: string]: unknown;
|
|
1602
1659
|
}>;
|
|
1603
1660
|
memoryLookupEntity(subject: string): Promise<{
|
|
1604
1661
|
subject: string;
|
|
@@ -1830,7 +1887,7 @@ declare class TeamsApi extends ApiBase {
|
|
|
1830
1887
|
|
|
1831
1888
|
//#endregion
|
|
1832
1889
|
//#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 {}
|
|
1890
|
+
interface AgentApiClient extends SyncApi, IntegrationsApi, WorkspaceApi, ConnectCredentialsApi, TeamsApi, ChatApi, SecretsApi, IdentityApi, MemoryApi, SearchApi, KnowledgeApi, DatabaseApi, MobileApi, RemoteApi, SelfApi, VoiceApi, ImagesApi, WebhooksApi {}
|
|
1834
1891
|
declare class AgentApiClient extends ApiBase {
|
|
1835
1892
|
constructor(config: AgentApiClientConfig);
|
|
1836
1893
|
}
|
|
@@ -1850,7 +1907,7 @@ interface ChatServiceClientOptions {
|
|
|
1850
1907
|
/** Agent API key for Bearer auth */
|
|
1851
1908
|
apiKey: string;
|
|
1852
1909
|
/** Called when the chat service sends an RPC request */
|
|
1853
|
-
onRequest: (request: RpcRequest) => void
|
|
1910
|
+
onRequest: (request: RpcRequest) => void | Promise<void>;
|
|
1854
1911
|
/** Called when connection state changes */
|
|
1855
1912
|
onConnectionChange?: (connected: boolean) => void;
|
|
1856
1913
|
/** Optional logger (defaults to console) */
|
|
@@ -1872,12 +1929,12 @@ interface Logger {
|
|
|
1872
1929
|
}
|
|
1873
1930
|
//#endregion
|
|
1874
1931
|
//#region src/client.d.ts
|
|
1875
|
-
|
|
1876
1932
|
declare class ChatServiceClient {
|
|
1877
1933
|
private readonly options;
|
|
1878
1934
|
private ws;
|
|
1879
1935
|
private stopped;
|
|
1880
1936
|
private connected;
|
|
1937
|
+
private connectionGeneration;
|
|
1881
1938
|
private retryCount;
|
|
1882
1939
|
private retryTimer;
|
|
1883
1940
|
private heartbeatTimer;
|
|
@@ -1886,7 +1943,7 @@ declare class ChatServiceClient {
|
|
|
1886
1943
|
private pendingRequests;
|
|
1887
1944
|
private requestCounter;
|
|
1888
1945
|
private messageQueue;
|
|
1889
|
-
private
|
|
1946
|
+
private queuedBytes;
|
|
1890
1947
|
constructor(options: ChatServiceClientOptions);
|
|
1891
1948
|
get isConnected(): boolean;
|
|
1892
1949
|
/** Start connecting to the chat service. */
|
|
@@ -1907,8 +1964,13 @@ declare class ChatServiceClient {
|
|
|
1907
1964
|
*/
|
|
1908
1965
|
sendRequest(method: string, params: Record<string, unknown>, timeoutMs?: number): Promise<Record<string, unknown>>;
|
|
1909
1966
|
private flushMessageQueue;
|
|
1967
|
+
private enqueueMessage;
|
|
1910
1968
|
private flushPendingRequests;
|
|
1969
|
+
private rejectPendingRequest;
|
|
1911
1970
|
private doConnect;
|
|
1971
|
+
private isCurrentSocket;
|
|
1972
|
+
private setConnected;
|
|
1973
|
+
private notifyConnectionChange;
|
|
1912
1974
|
private handleMessage;
|
|
1913
1975
|
private scheduleReconnect;
|
|
1914
1976
|
/**
|
|
@@ -2080,14 +2142,20 @@ declare const WARM_STREAMING_SUPPORTED = false;
|
|
|
2080
2142
|
* posture). An inbound chat message could try to induce a destructive shell
|
|
2081
2143
|
* command, and these turns run unattended on the user's machine. We therefore
|
|
2082
2144
|
* pass an explicit allow-list of read/analysis/edit tools and DENY Bash by
|
|
2083
|
-
* default, and use `--permission-mode
|
|
2145
|
+
* default, and use `--permission-mode dontAsk` (NEVER `bypassPermissions` /
|
|
2084
2146
|
* `--dangerously-skip-permissions`). See DEVELOPING.md → "Tool-permission
|
|
2085
2147
|
* posture". Bash is intentionally absent — a bridged turn cannot run arbitrary
|
|
2086
2148
|
* shell. Callers that want a wider set pass `allowedTools` explicitly.
|
|
2087
2149
|
*/
|
|
2088
2150
|
declare const DEFAULT_ALLOWED_TOOLS: readonly ["Read", "Grep", "Glob", "LS", "Edit", "Write", "WebFetch", "WebSearch", "Task", "TodoWrite"];
|
|
2089
|
-
|
|
2090
|
-
|
|
2151
|
+
declare const CLAUDE_PERMISSION_MODES: readonly ["acceptEdits", "auto", "manual", "dontAsk", "plan"];
|
|
2152
|
+
type ClaudePermissionMode = (typeof CLAUDE_PERMISSION_MODES)[number];
|
|
2153
|
+
/**
|
|
2154
|
+
* Headless-safe permission posture supported by current Claude CLI releases.
|
|
2155
|
+
* Allow-listed tools run; any permission prompt the bridge cannot answer is
|
|
2156
|
+
* denied. `bypassPermissions` is deliberately not representable.
|
|
2157
|
+
*/
|
|
2158
|
+
declare const DEFAULT_PERMISSION_MODE: ClaudePermissionMode;
|
|
2091
2159
|
/** How a turn ended, surfaced to the host so it can settle / persist. */
|
|
2092
2160
|
interface DriverTurnResult {
|
|
2093
2161
|
/** The claude session id observed on the `system:init` event (for --resume). */
|
|
@@ -2119,7 +2187,7 @@ interface RunTurnParams {
|
|
|
2119
2187
|
/** Tool allow-list (defaults to DEFAULT_ALLOWED_TOOLS). */
|
|
2120
2188
|
allowedTools?: readonly string[];
|
|
2121
2189
|
/** Permission mode (defaults to DEFAULT_PERMISSION_MODE — never bypass). */
|
|
2122
|
-
permissionMode?:
|
|
2190
|
+
permissionMode?: ClaudePermissionMode;
|
|
2123
2191
|
/** Per-emission callback so the host can stream deltas/activity live. */
|
|
2124
2192
|
onEmission: (emission: MapperEmission) => void;
|
|
2125
2193
|
/** Wall-clock override for the mapper (tests). Defaults to Date.now. */
|
|
@@ -2134,6 +2202,8 @@ interface RunTurnParams {
|
|
|
2134
2202
|
* cap, but the late settle is harmlessly no-op'd by the chat service.
|
|
2135
2203
|
*/
|
|
2136
2204
|
declare const TURN_TIMEOUT_MS = 300000;
|
|
2205
|
+
/** Grace after SIGINT before SIGKILL + local settlement. Keeps E2 under 305s. */
|
|
2206
|
+
declare const TERMINATION_GRACE_MS = 2000;
|
|
2137
2207
|
/**
|
|
2138
2208
|
* Spawns and drives `claude` subprocesses. Tracks a SINGLE in-flight child, so
|
|
2139
2209
|
* the host creates ONE driver PER TURN (`ClaudeCodeHost.makeDriver`) — a driver
|
|
@@ -2142,6 +2212,7 @@ declare const TURN_TIMEOUT_MS = 300000;
|
|
|
2142
2212
|
*/
|
|
2143
2213
|
declare class SessionDriver {
|
|
2144
2214
|
private child;
|
|
2215
|
+
private abortCurrent;
|
|
2145
2216
|
private readonly bin;
|
|
2146
2217
|
private readonly baseEnv;
|
|
2147
2218
|
private readonly log;
|
|
@@ -2215,6 +2286,9 @@ declare class ClaudeCodeHost {
|
|
|
2215
2286
|
private readonly seenIdempotencyKeys;
|
|
2216
2287
|
/** RPC sessionKey → resolved SessionDriver so chat.abort can SIGINT the child. */
|
|
2217
2288
|
private activeDriverBySession;
|
|
2289
|
+
private claudeSessionSave;
|
|
2290
|
+
private stopping;
|
|
2291
|
+
private stopPromise;
|
|
2218
2292
|
constructor(cfg: ClaudeCodeHostConfig, deps?: {
|
|
2219
2293
|
/** Per-turn driver factory (test seam). Called once per turn. */
|
|
2220
2294
|
makeDriver?: () => SessionDriver;
|
|
@@ -2223,8 +2297,8 @@ declare class ClaudeCodeHost {
|
|
|
2223
2297
|
});
|
|
2224
2298
|
/** Start the chat WS. Non-blocking — the client reconnects internally. */
|
|
2225
2299
|
start(): Promise<void>;
|
|
2226
|
-
/** Stop
|
|
2227
|
-
stop(): void
|
|
2300
|
+
/** Stop admission, abort owned children, and give active turns time to settle. */
|
|
2301
|
+
stop(): Promise<void>;
|
|
2228
2302
|
/**
|
|
2229
2303
|
* Inbound RPC dispatch. Invoked by the chat client's `onRequest` in
|
|
2230
2304
|
* production; also the test seam (drive `agent`/`chat.abort`/… directly).
|
|
@@ -2246,6 +2320,7 @@ declare class ClaudeCodeHost {
|
|
|
2246
2320
|
private ensureSession;
|
|
2247
2321
|
private loadClaudeSessionIds;
|
|
2248
2322
|
private saveClaudeSessionIds;
|
|
2323
|
+
private rememberClaudeSessionId;
|
|
2249
2324
|
private pruneIdempotency;
|
|
2250
2325
|
}
|
|
2251
2326
|
/** Strip the `agent:{agentId}:` prefix from a full server session key. */
|
|
@@ -2404,4 +2479,4 @@ declare function listSessions(filters?: {
|
|
|
2404
2479
|
*/
|
|
2405
2480
|
declare function resolveHostConfig(): ClaudeCodeHostConfig;
|
|
2406
2481
|
//#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 };
|
|
2482
|
+
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 };
|