agl 43.6.0 → 43.8.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/changelog.md +27 -0
- package/dist_serve/bundle.js +1801 -1783
- package/dist_serve/bundle.js.map +2 -2
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/interfaces.d.ts +35 -0
- package/dist_ts/aglapi/interfaces.js +9 -1
- package/dist_ts/classes.accountsactions.d.ts +3 -1
- package/dist_ts/classes.accountsactions.js +17 -1
- package/dist_ts/classes.apnsclient.d.ts +97 -0
- package/dist_ts/classes.apnsclient.js +363 -0
- package/dist_ts/classes.authmodels.js +19 -6
- package/dist_ts/classes.authstore.js +15 -2
- package/dist_ts/classes.cli.js +8 -1
- package/dist_ts/classes.controller.d.ts +33 -6
- package/dist_ts/classes.controller.js +254 -12
- package/dist_ts/classes.controllerdevices.d.ts +35 -7
- package/dist_ts/classes.controllerdevices.js +86 -13
- package/dist_ts/classes.controllerpush.d.ts +111 -0
- package/dist_ts/classes.controllerpush.js +299 -0
- package/dist_ts/classes.fcmclient.d.ts +78 -0
- package/dist_ts/classes.fcmclient.js +278 -0
- package/dist_ts/classes.inbox.d.ts +10 -2
- package/dist_ts/classes.inbox.js +9 -2
- package/dist_ts/classes.inferencerouter.d.ts +21 -3
- package/dist_ts/classes.inferencerouter.js +40 -17
- package/dist_ts/classes.inferenceservice.js +2 -2
- package/dist_ts/classes.mcpclient.d.ts +5 -0
- package/dist_ts/classes.mcpclient.js +18 -6
- package/dist_ts/classes.mcpcontrollerhost.d.ts +3 -0
- package/dist_ts/classes.mcpcontrollerhost.js +19 -1
- package/dist_ts/classes.mcpvalidation.js +4 -1
- package/dist_ts/classes.mcpworkercaller.d.ts +6 -0
- package/dist_ts/classes.mcpworkercaller.js +26 -4
- package/dist_ts/classes.pushdelivery.d.ts +115 -0
- package/dist_ts/classes.pushdelivery.js +311 -0
- package/dist_ts/classes.pushhandover.d.ts +46 -0
- package/dist_ts/classes.pushhandover.js +131 -0
- package/dist_ts/classes.pushregistrations.d.ts +96 -0
- package/dist_ts/classes.pushregistrations.js +263 -0
- package/dist_ts/classes.pushsettings.d.ts +125 -0
- package/dist_ts/classes.pushsettings.js +377 -0
- package/dist_ts/classes.workercallers.d.ts +73 -2
- package/dist_ts/classes.workercallers.js +354 -43
- package/dist_ts/driver/classes.directreports.d.ts +5 -0
- package/dist_ts/driver/classes.directreports.js +3 -2
- package/dist_ts/fleet/classes.workerlaunches.d.ts +6 -4
- package/dist_ts/fleet/classes.workerlaunches.js +10 -9
- package/dist_ts/fleet/classes.workers.d.ts +12 -2
- package/dist_ts/fleet/classes.workers.js +82 -2
- package/dist_ts/functions.deviceapi.d.ts +23 -3
- package/dist_ts/functions.deviceapi.js +41 -3
- package/dist_ts/functions.inferencecli.js +2 -1
- package/dist_ts/functions.pushcli.d.ts +43 -0
- package/dist_ts/functions.pushcli.js +201 -0
- package/dist_ts/functions.pushcredentials.d.ts +53 -0
- package/dist_ts/functions.pushcredentials.js +111 -0
- package/dist_ts/functions.pushwire.d.ts +8 -0
- package/dist_ts/functions.pushwire.js +83 -0
- package/dist_ts/functions.remotecli.d.ts +2 -2
- package/dist_ts/functions.remotecli.js +4 -4
- package/dist_ts/functions.workercallervalidation.js +3 -2
- package/dist_ts/functions.workerprocessproof.d.ts +12 -0
- package/dist_ts/functions.workerprocessproof.js +32 -1
- package/dist_ts/interfaces.auth.d.ts +27 -3
- package/dist_ts/interfaces.auth.js +10 -1
- package/dist_ts/interfaces.lifecycle.d.ts +7 -1
- package/dist_ts/interfaces.push.d.ts +69 -0
- package/dist_ts/interfaces.push.js +25 -0
- package/dist_ts/plugins.d.ts +5 -2
- package/dist_ts/plugins.js +7 -3
- package/dist_ts_authswitch/authority-contract.d.ts +26 -0
- package/dist_ts_authswitch/authority-contract.js +1 -1
- package/dist_ts_authswitch/authority-overview.d.ts +8 -0
- package/dist_ts_authswitch/authority-overview.js +10 -4
- package/dist_ts_authswitch/authority-placement.d.ts +16 -9
- package/dist_ts_authswitch/authority-placement.js +10 -7
- package/dist_ts_authswitch/authority-priority.d.ts +20 -0
- package/dist_ts_authswitch/authority-priority.js +21 -0
- package/dist_ts_authswitch/classes.authoritybroker.d.ts +7 -0
- package/dist_ts_authswitch/classes.authoritybroker.js +26 -2
- package/dist_ts_authswitch/classes.authoritycli.d.ts +1 -0
- package/dist_ts_authswitch/classes.authoritycli.js +43 -3
- package/dist_ts_authswitch/classes.authorityclient.d.ts +6 -1
- package/dist_ts_authswitch/classes.authorityclient.js +12 -4
- package/dist_ts_authswitch/classes.authoritydaemon.js +7 -1
- package/dist_ts_authswitch/classes.authoritydatabase.d.ts +6 -0
- package/dist_ts_authswitch/classes.authoritydatabase.js +13 -2
- package/dist_ts_authswitch/classes.authoritymodels.d.ts +7 -0
- package/dist_ts_authswitch/classes.authoritymodels.js +17 -8
- package/dist_ts_interfaces/devices.d.ts +178 -2
- package/dist_ts_interfaces/devices.js +24 -2
- package/dist_ts_interfaces/index.d.ts +1 -0
- package/dist_ts_interfaces/index.js +2 -1
- package/dist_ts_interfaces/mcprequests.d.ts +3 -2
- package/dist_ts_interfaces/mcprequests.js +3 -1
- package/dist_ts_interfaces/push.d.ts +166 -0
- package/dist_ts_interfaces/push.js +24 -0
- package/dist_ts_interfaces/requests.accounts.d.ts +19 -0
- package/dist_ts_interfaces/requests.accounts.js +1 -1
- package/dist_ts_interfaces/requests.d.ts +2 -2
- package/dist_ts_interfaces/requests.js +1 -1
- package/dist_ts_interfaces/workercallers.d.ts +43 -3
- package/docs/authswitch.md +25 -0
- package/package.json +1 -1
- package/readme.md +93 -16
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/interfaces.ts +8 -0
- package/ts/classes.accountsactions.ts +25 -0
- package/ts/classes.apnsclient.ts +389 -0
- package/ts/classes.authmodels.ts +21 -5
- package/ts/classes.authstore.ts +14 -1
- package/ts/classes.cli.ts +7 -0
- package/ts/classes.controller.ts +277 -10
- package/ts/classes.controllerdevices.ts +94 -12
- package/ts/classes.controllerpush.ts +351 -0
- package/ts/classes.fcmclient.ts +292 -0
- package/ts/classes.inbox.ts +13 -2
- package/ts/classes.inferencerouter.ts +61 -16
- package/ts/classes.inferenceservice.ts +1 -1
- package/ts/classes.mcpclient.ts +20 -5
- package/ts/classes.mcpcontrollerhost.ts +20 -0
- package/ts/classes.mcpvalidation.ts +2 -0
- package/ts/classes.mcpworkercaller.ts +24 -2
- package/ts/classes.pushdelivery.ts +378 -0
- package/ts/classes.pushhandover.ts +98 -0
- package/ts/classes.pushregistrations.ts +244 -0
- package/ts/classes.pushsettings.ts +428 -0
- package/ts/classes.workercallers.ts +329 -37
- package/ts/driver/classes.directreports.ts +7 -1
- package/ts/fleet/classes.workerlaunches.ts +9 -7
- package/ts/fleet/classes.workers.ts +65 -2
- package/ts/functions.deviceapi.ts +52 -2
- package/ts/functions.inferencecli.ts +1 -0
- package/ts/functions.pushcli.ts +212 -0
- package/ts/functions.pushcredentials.ts +129 -0
- package/ts/functions.pushwire.ts +106 -0
- package/ts/functions.remotecli.ts +3 -2
- package/ts/functions.workercallervalidation.ts +2 -1
- package/ts/functions.workerprocessproof.ts +34 -0
- package/ts/interfaces.auth.ts +27 -3
- package/ts/interfaces.lifecycle.ts +7 -1
- package/ts/interfaces.push.ts +78 -0
- package/ts/plugins.ts +6 -1
- package/ts_authswitch/authority-contract.ts +21 -0
- package/ts_authswitch/authority-overview.ts +19 -5
- package/ts_authswitch/authority-placement.ts +18 -10
- package/ts_authswitch/authority-priority.ts +25 -0
- package/ts_authswitch/classes.authoritybroker.ts +26 -1
- package/ts_authswitch/classes.authoritycli.ts +48 -2
- package/ts_authswitch/classes.authorityclient.ts +14 -4
- package/ts_authswitch/classes.authoritydaemon.ts +8 -1
- package/ts_authswitch/classes.authoritydatabase.ts +11 -1
- package/ts_authswitch/classes.authoritymodels.ts +17 -6
- package/ts_authswitch/readme.md +1 -1
- package/ts_interfaces/devices.schema.json +327 -0
- package/ts_interfaces/devices.ts +206 -1
- package/ts_interfaces/index.ts +1 -0
- package/ts_interfaces/mcprequests.ts +3 -0
- package/ts_interfaces/push.ts +162 -0
- package/ts_interfaces/requests.accounts.ts +17 -0
- package/ts_interfaces/requests.ts +2 -0
- package/ts_interfaces/workercallers.ts +34 -2
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/accounts.plugins.ts +4 -2
- package/ts_web/classes.accountsreadmodel.ts +36 -2
- package/ts_web/elements.accounts.ts +48 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type * as plugins from './plugins.js';
|
|
2
|
+
import type { TDevicePushEnvironment, TDevicePushFailureReason, TDevicePushPlatform } from './devices.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Notifications from the host (AGL-1639): the push settings the owner sets with `agl push` against the running
|
|
6
|
+
* controller, through its private channel with the local owner capability. The answers name what the host holds for
|
|
7
|
+
* each push service (key id, team id, topic, Firebase project, service account address), never a key, a token or a
|
|
8
|
+
* device's push token.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* What the host holds for one push service: `unset`, no credential; `ready`, a credential it sends with;
|
|
13
|
+
* `refused`, Apple or Google refused it, and nothing is sent on the platform until the owner sets it again;
|
|
14
|
+
* `unreadable`, the stored credential cannot be read or unsealed on this machine, so the owner sets it again.
|
|
15
|
+
*/
|
|
16
|
+
export type TPushCredentialState = 'unset' | 'ready' | 'refused' | 'unreadable';
|
|
17
|
+
|
|
18
|
+
/** A send that failed, as `agl push status` shows it: the reason and, when the push service named one, its code. */
|
|
19
|
+
export interface IPushFailureStatus {
|
|
20
|
+
/** Unix milliseconds. */
|
|
21
|
+
at: number;
|
|
22
|
+
reason: TDevicePushFailureReason;
|
|
23
|
+
/** The push service's own code (an APNs `reason`, an FCM `errorCode` or an OAuth `error`), never its message. */
|
|
24
|
+
vendorReason?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Set when the push service refused while its clock and the host's were apart (Google's `invalid_grant` with its
|
|
27
|
+
* `Date` more than 60 s off the host's clock): the service's clock minus the host's, in milliseconds, so a positive
|
|
28
|
+
* value is a host clock behind. The send is `service_failed` and tried again, the credential kept.
|
|
29
|
+
*/
|
|
30
|
+
clockSkewMs?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A clock skew as `agl push status` and the failure journal name it: how far apart, and which clock is behind. */
|
|
34
|
+
export const pushClockSkewText = (clockSkewMsArg: number): string => (
|
|
35
|
+
`${Math.round(Math.abs(clockSkewMsArg) / 1000)} s apart, the host's clock ${clockSkewMsArg > 0 ? 'behind' : 'ahead'}`
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
/** What the host holds for Apple's push service. */
|
|
39
|
+
export interface IPushApnsStatus {
|
|
40
|
+
state: TPushCredentialState;
|
|
41
|
+
/** The key's 10-character id; absent while unset. */
|
|
42
|
+
keyId?: string;
|
|
43
|
+
/** The 10-character Apple team id; absent while unset. */
|
|
44
|
+
teamId?: string;
|
|
45
|
+
/** The app's bundle id, the topic every notification names; absent while unset. */
|
|
46
|
+
topic?: string;
|
|
47
|
+
/** Unix milliseconds the credential was set. */
|
|
48
|
+
setAt?: number;
|
|
49
|
+
/** While `refused`: when and why Apple refused the credential. */
|
|
50
|
+
refused?: IPushFailureStatus;
|
|
51
|
+
/** The paired devices registered for APNs notifications. */
|
|
52
|
+
registrations: number;
|
|
53
|
+
/** The last send on the platform that failed since the controller started. */
|
|
54
|
+
lastFailure?: IPushFailureStatus;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** What the host holds for Firebase Cloud Messaging. */
|
|
58
|
+
export interface IPushFcmStatus {
|
|
59
|
+
state: TPushCredentialState;
|
|
60
|
+
/** The Firebase project id; absent while unset. */
|
|
61
|
+
projectId?: string;
|
|
62
|
+
/** The service account's address; absent while unset. */
|
|
63
|
+
clientEmail?: string;
|
|
64
|
+
/** Unix milliseconds the credential was set. */
|
|
65
|
+
setAt?: number;
|
|
66
|
+
/** While `refused`: when and why Google refused the credential. */
|
|
67
|
+
refused?: IPushFailureStatus;
|
|
68
|
+
/** The paired devices registered for FCM notifications. */
|
|
69
|
+
registrations: number;
|
|
70
|
+
/** The last send on the platform that failed since the controller started. */
|
|
71
|
+
lastFailure?: IPushFailureStatus;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The host's push settings: one for every device of the host. */
|
|
75
|
+
export interface IPushStatus {
|
|
76
|
+
/** Whether notifications carry previews (`IDevicePushInboxData`); off unless the owner turns it on. */
|
|
77
|
+
previews: boolean;
|
|
78
|
+
apns: IPushApnsStatus;
|
|
79
|
+
fcm: IPushFcmStatus;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A change to the push settings: the settings after it, and whether it changed anything. */
|
|
83
|
+
export interface IPushChange {
|
|
84
|
+
changed: boolean;
|
|
85
|
+
status: IPushStatus;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* What the owner's test notification came to on one device: `delivered`; `unregistered`, the push service no longer
|
|
90
|
+
* knows the device's token (the registration was removed, and the app registers again on its next connect);
|
|
91
|
+
* `unavailable`, the host holds no usable credential for the device's platform, so nothing was sent; `no_answer`, the
|
|
92
|
+
* push service did not answer within `pushTestAnswerWaitMs`, and the notification may still arrive; or why it did not go out.
|
|
93
|
+
*/
|
|
94
|
+
export type TPushTestOutcome = 'delivered' | 'unregistered' | 'unavailable' | 'no_answer' | TDevicePushFailureReason;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* How long `agl push test` waits for each device's answer: under the CLI's 30 s request timeout, although one attempt may
|
|
98
|
+
* take a token request, a send, a token asked anew and a send again, at 15 s each.
|
|
99
|
+
*/
|
|
100
|
+
export const pushTestAnswerWaitMs = 20_000;
|
|
101
|
+
|
|
102
|
+
/** One registered device's answer to `agl push test`: never its token. */
|
|
103
|
+
export interface IPushTestResult {
|
|
104
|
+
deviceId: string;
|
|
105
|
+
name: string;
|
|
106
|
+
platform: TDevicePushPlatform;
|
|
107
|
+
environment?: TDevicePushEnvironment;
|
|
108
|
+
outcome: TPushTestOutcome;
|
|
109
|
+
/** The push service's own code, when it named one. */
|
|
110
|
+
vendorReason?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Every `agl push` request: the request without the owner capability, and its answer. */
|
|
114
|
+
export interface IPushOperations {
|
|
115
|
+
status: { request: Record<never, never>; response: IPushStatus };
|
|
116
|
+
'apns.set': {
|
|
117
|
+
/** `signingKey` is the AuthKey .p8 file's text, which the controller seals and never repeats. */
|
|
118
|
+
request: { keyId: string; teamId: string; topic?: string; signingKey: string };
|
|
119
|
+
response: IPushChange;
|
|
120
|
+
};
|
|
121
|
+
'apns.unset': { request: Record<never, never>; response: IPushChange };
|
|
122
|
+
'fcm.set': {
|
|
123
|
+
/** `serviceAccount` is the service account key file's JSON text, which the controller seals and never repeats. */
|
|
124
|
+
request: { serviceAccount: string };
|
|
125
|
+
response: IPushChange;
|
|
126
|
+
};
|
|
127
|
+
'fcm.unset': { request: Record<never, never>; response: IPushChange };
|
|
128
|
+
previews: { request: { previews: boolean }; response: IPushChange };
|
|
129
|
+
/** Sends the test notification (`IDevicePushTestData`) to every registered device, or to the one `deviceId` names. */
|
|
130
|
+
test: { request: { deviceId?: string }; response: { results: IPushTestResult[] } };
|
|
131
|
+
}
|
|
132
|
+
export type TPushOperation = keyof IPushOperations;
|
|
133
|
+
export const pushOperations = ['status', 'apns.set', 'apns.unset', 'fcm.set', 'fcm.unset', 'previews', 'test'] as const satisfies readonly TPushOperation[];
|
|
134
|
+
|
|
135
|
+
/** The request fields that carry a secret: no answer, log or error repeats them, and the request's echo redacts them. */
|
|
136
|
+
export const pushSecretRequestFields = ['signingKey', 'serviceAccount'] as const;
|
|
137
|
+
|
|
138
|
+
/** Why the controller refused an `agl push` request; its sentence names the cause, never the input. */
|
|
139
|
+
export const pushErrorCodes = ['push_credential_invalid', 'push_device_unknown', 'push_unavailable'] as const;
|
|
140
|
+
export type TPushErrorCode = (typeof pushErrorCodes)[number];
|
|
141
|
+
|
|
142
|
+
export const controllerMcpPushMethods = [
|
|
143
|
+
'agl.mcp.push.status',
|
|
144
|
+
'agl.mcp.push.apns.set',
|
|
145
|
+
'agl.mcp.push.apns.unset',
|
|
146
|
+
'agl.mcp.push.fcm.set',
|
|
147
|
+
'agl.mcp.push.fcm.unset',
|
|
148
|
+
'agl.mcp.push.previews',
|
|
149
|
+
'agl.mcp.push.test',
|
|
150
|
+
] as const satisfies readonly `agl.mcp.push.${TPushOperation}`[];
|
|
151
|
+
export type TControllerMcpPushMethod = (typeof controllerMcpPushMethods)[number];
|
|
152
|
+
export type TControllerMcpPushRequest<TOperation extends TPushOperation> = {
|
|
153
|
+
method: `agl.mcp.push.${TOperation}`;
|
|
154
|
+
request: IPushOperations[TOperation]['request'] & { ownerToken: string };
|
|
155
|
+
response: IPushOperations[TOperation]['response'];
|
|
156
|
+
} & plugins.typedrequestInterfaces.ITypedRequest;
|
|
157
|
+
export type TControllerMcpPushTypedRequest = { [TOperation in TPushOperation]: TControllerMcpPushRequest<TOperation> }[TPushOperation];
|
|
158
|
+
|
|
159
|
+
/** The operation a private push method names. */
|
|
160
|
+
export const pushOperationOf = (methodArg: TControllerMcpPushMethod): TPushOperation => (
|
|
161
|
+
methodArg.slice('agl.mcp.push.'.length) as TPushOperation
|
|
162
|
+
);
|
|
@@ -273,6 +273,23 @@ export interface IReq_ControllerAccountsRenewal extends plugins.typedrequestInte
|
|
|
273
273
|
response: { answer: TControllerAccountsAnswer<TControllerAccount> };
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Gives an account the owner's priority (AGL-1809) for 24 hours from now, by the accounts service's clock, or ends it
|
|
278
|
+
* with `priority: false`; giving it to an account that holds it starts the 24 hours again. Until it ends, AGL's inference
|
|
279
|
+
* proxy places a new session on the account before any account of its pool without one, as long as it takes the
|
|
280
|
+
* request; several accounts can hold it. Any account can have one. `expectedRevision` is the revision the view showed,
|
|
281
|
+
* so a change of an account that changed meanwhile is refused as `account_changed` by the service. The answer arrives
|
|
282
|
+
* only once the projection shows the result.
|
|
283
|
+
*/
|
|
284
|
+
export interface IReq_ControllerAccountsPriority extends plugins.typedrequestInterfaces.implementsTR<
|
|
285
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
286
|
+
IReq_ControllerAccountsPriority
|
|
287
|
+
> {
|
|
288
|
+
method: 'controller.accounts.priority';
|
|
289
|
+
request: { accountId: string; expectedRevision: number; priority: boolean };
|
|
290
|
+
response: { answer: TControllerAccountsAnswer<TControllerAccount> };
|
|
291
|
+
}
|
|
292
|
+
|
|
276
293
|
/** Duration validation shared with the authority; no implicit duration is supplied. */
|
|
277
294
|
export const isControllerReserveLiftHours = plugins.authswitchAuthority.isAuthSwitchReserveLiftHours;
|
|
278
295
|
|
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
IReq_ControllerAccountsSpendLimit,
|
|
34
34
|
IReq_ControllerAccountsClaudeCode,
|
|
35
35
|
IReq_ControllerAccountsRenewal,
|
|
36
|
+
IReq_ControllerAccountsPriority,
|
|
36
37
|
IReq_ControllerAccountsSnapshot,
|
|
37
38
|
IReq_ControllerAccountsUsageGet,
|
|
38
39
|
IReq_ControllerAccountsUsageRecheck,
|
|
@@ -413,6 +414,7 @@ export type TControllerRequest =
|
|
|
413
414
|
| IReq_ControllerAccountsSpendLimit
|
|
414
415
|
| IReq_ControllerAccountsClaudeCode
|
|
415
416
|
| IReq_ControllerAccountsRenewal
|
|
417
|
+
| IReq_ControllerAccountsPriority
|
|
416
418
|
| IReq_ControllerAccountsRemove
|
|
417
419
|
| IReq_ControllerAccountsAdd
|
|
418
420
|
| IReq_ControllerAccountsReauth
|
|
@@ -60,12 +60,18 @@ export interface IFleetWorkerCallerHooks {
|
|
|
60
60
|
}>;
|
|
61
61
|
getWorkerCallerStatus(launchId: string): IWorkerCallerReadiness;
|
|
62
62
|
/**
|
|
63
|
-
* Revokes one launch, or the current launch of a worker, also one the controller kept from before a restart
|
|
64
|
-
* reason but `generation_change` revokes it for good: its
|
|
63
|
+
* Revokes one launch, or the current launch of a worker, also one the controller kept from before a restart or
|
|
64
|
+
* recorded for a bridge it identified by its process. Every reason but `generation_change` revokes it for good: its
|
|
65
|
+
* kept binding is deleted with it.
|
|
65
66
|
*/
|
|
66
67
|
revokeWorkerCaller(request: ({ launchId: string } | { workerId: string }) & {
|
|
67
68
|
reason: 'failure' | 'stop' | 'replacement' | 'generation_change' | 'cancelled';
|
|
68
69
|
}): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* The fleet adopted or re-bound a worker: every process whose bridge the controller refused to identify is
|
|
72
|
+
* identified afresh at its bridge's next call.
|
|
73
|
+
*/
|
|
74
|
+
clearCallerRefusals(): void;
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
/** The background job a Claude worker's launch is bound to, as the controller asks the fleet about it. */
|
|
@@ -87,6 +93,27 @@ export type TWorkerClaudeJobObservation =
|
|
|
87
93
|
| { state: 'ended'; reason: string }
|
|
88
94
|
| { state: 'unproven'; reason: string };
|
|
89
95
|
|
|
96
|
+
/**
|
|
97
|
+
* The process an MCP bridge runs under (its direct parent), which the controller proved to run an installed Claude Code
|
|
98
|
+
* release, and that process's own parent, as the controller asks the fleet whose job it is.
|
|
99
|
+
*/
|
|
100
|
+
export interface IWorkerClaudeProcessRequest {
|
|
101
|
+
pid: number;
|
|
102
|
+
parentPid: number;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* What the fleet names a process for: `identified` when a fresh inventory of the fleet's Claude homes lists it exactly
|
|
107
|
+
* once, as the process of a background job with an agent id whose session it lists once, and exactly one stored worker
|
|
108
|
+
* of any owner, a live Claude worker without a dispatch in flight or a lost one, binds that session under the home that
|
|
109
|
+
* lists it. Otherwise `refused` by the check that failed: `parent` when the process is not the job's but its own parent
|
|
110
|
+
* is (the bridge runs one level too deep), `inventory` or `worker`; with the worker when one is named, and whether the
|
|
111
|
+
* refusal holds while the process runs (`forGood`) or may pass soon.
|
|
112
|
+
*/
|
|
113
|
+
export type TWorkerClaudeProcessIdentification =
|
|
114
|
+
| { state: 'identified'; workerId: string; projectId: string; nativeSessionId: string; jobId: string }
|
|
115
|
+
| { state: 'refused'; check: 'parent' | 'inventory' | 'worker'; reason: string; forGood: boolean; workerId?: string; nativeSessionId?: string };
|
|
116
|
+
|
|
90
117
|
export interface IWorkerCallerSubject {
|
|
91
118
|
kind: 'worker_launch';
|
|
92
119
|
launchId: string;
|
|
@@ -101,10 +128,15 @@ export interface IWorkerCallerSubject {
|
|
|
101
128
|
workerName: string;
|
|
102
129
|
}
|
|
103
130
|
|
|
131
|
+
/**
|
|
132
|
+
* A bridge enrolls with the launch its MCP configuration gave it, a Codex challenge or thread, or, holding none, its
|
|
133
|
+
* process id alone: the controller then identifies it by its process chain.
|
|
134
|
+
*/
|
|
104
135
|
export type TWorkerCallerEnrollment = { bridgePid: number } & (
|
|
105
136
|
| { launchId: string; launchGeneration: string }
|
|
106
137
|
| { challenge: string; nativeThreadId: string }
|
|
107
138
|
| { nativeThreadId: string }
|
|
139
|
+
| Record<never, never>
|
|
108
140
|
);
|
|
109
141
|
|
|
110
142
|
export interface IWorkerCallerEnrollmentResponse extends IWorkerCallerReadiness {
|
|
@@ -15,9 +15,11 @@ import * as authswitchSubscription from '../ts_authswitch/authority-subscription
|
|
|
15
15
|
import * as authswitchSpend from '../ts_authswitch/authority-spend.js';
|
|
16
16
|
// A Claude sign-in's monthly renewal: its next one, rolled forward as placement rolls it; it imports nothing.
|
|
17
17
|
import * as authswitchRenewal from '../ts_authswitch/authority-renewal.js';
|
|
18
|
+
// An account's priority as its owner set it: whether it holds now, as placement judges it; it imports nothing.
|
|
19
|
+
import * as authswitchPriority from '../ts_authswitch/authority-priority.js';
|
|
18
20
|
// The service's contract, which the controller's interfaces load already: the processes holding a Claude sign-in, in
|
|
19
21
|
// the words the command line uses.
|
|
20
22
|
import * as authswitchAuthority from '../ts_authswitch/authority-contract.js';
|
|
21
23
|
|
|
22
|
-
export { authswitchAuthority, authswitchPreuseText, authswitchRenewal, authswitchSpend,
|
|
23
|
-
authswitchUsageLimit, authswitchUsageWindows };
|
|
24
|
+
export { authswitchAuthority, authswitchPreuseText, authswitchPriority, authswitchRenewal, authswitchSpend,
|
|
25
|
+
authswitchSubscription, authswitchUsageLimit, authswitchUsageWindows };
|
|
@@ -149,6 +149,8 @@ export type TAccountActionId =
|
|
|
149
149
|
| 'claudeCode'
|
|
150
150
|
| 'renewal'
|
|
151
151
|
| 'clearRenewal'
|
|
152
|
+
| 'priority'
|
|
153
|
+
| 'clearPriority'
|
|
152
154
|
| 'addApiKey'
|
|
153
155
|
| 'remove'
|
|
154
156
|
| 'usage'
|
|
@@ -363,6 +365,13 @@ export interface IAccountRow {
|
|
|
363
365
|
* one and for every other account.
|
|
364
366
|
*/
|
|
365
367
|
renewsAt: string | null;
|
|
368
|
+
/**
|
|
369
|
+
* When the owner's priority on the account ends, while it holds at the view's time (ISO 8601 UTC, AGL-1809), or `null`
|
|
370
|
+
* without one, once it ended and on a removed account.
|
|
371
|
+
*/
|
|
372
|
+
priorityUntil: string | null;
|
|
373
|
+
/** The priority as a badge beside its actions: `Priority until 14:05`, in local time; `null` without one. */
|
|
374
|
+
priorityStatus: IAccountStatus | null;
|
|
366
375
|
/** What a removal does that the owner must know, said with the removal; empty for a sign-in. */
|
|
367
376
|
removeNote: string;
|
|
368
377
|
label: string;
|
|
@@ -1347,12 +1356,27 @@ export const renewalListText = (renewsAtArg: string | null, nowArg: number): str
|
|
|
1347
1356
|
};
|
|
1348
1357
|
|
|
1349
1358
|
/**
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1359
|
+
* An account's priority as its row and its page say it (AGL-1809), in the reader's local time: `priority until 14:05`,
|
|
1360
|
+
* or `priority until tomorrow 14:05` when it ends on the next day, since it holds 24 hours at most; empty without one
|
|
1361
|
+
* or once it ended.
|
|
1362
|
+
*/
|
|
1363
|
+
export const priorityText = (priorityUntilArg: string | null, nowArg: number): string => {
|
|
1364
|
+
const until = plugins.authswitchPriority.authSwitchPriorityUntil(priorityUntilArg, nowArg);
|
|
1365
|
+
if (until === null) return '';
|
|
1366
|
+
const end = plugins.authswitchPreuseText.localDateTime(until);
|
|
1367
|
+
const today = plugins.authswitchPreuseText.localDateTime(new Date(nowArg).toISOString()).slice(0, 10);
|
|
1368
|
+
return `priority until ${end.slice(0, 10) === today ? '' : 'tomorrow '}${end.slice(11)}`;
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* The list row's second line: the owner's priority while it holds, then who the account is -- email and plan, or a
|
|
1373
|
+
* key's identity -- and who uses it. A Claude sign-in says when it renews instead of naming the AGL proxy, which every
|
|
1374
|
+
* one of them is used by.
|
|
1352
1375
|
*/
|
|
1353
1376
|
const listMeta = (accountArg: TAccount, chipsArg: readonly IAccountHarnessChip[], nowArg: number): string => {
|
|
1354
1377
|
const claudeSignIn = !isApiKeyAccount(accountArg) && accountArg.providerId === 'anthropic';
|
|
1355
1378
|
return [
|
|
1379
|
+
priorityText(accountArg.priorityUntil, nowArg),
|
|
1356
1380
|
...isApiKeyAccount(accountArg) ? [keyIdentityText(accountArg)] : [
|
|
1357
1381
|
accountArg.email && accountArg.email !== accountArg.label ? accountArg.email : '',
|
|
1358
1382
|
accountArg.plan ? `${accountArg.plan} plan` : '',
|
|
@@ -1593,6 +1617,9 @@ const serviceRow = (
|
|
|
1593
1617
|
const claudeSignIn = !apiKey && accountArg.providerId === 'anthropic';
|
|
1594
1618
|
const provider = keyProvider(accountArg.providerId);
|
|
1595
1619
|
const identity = apiKey ? keyIdentityText(accountArg) : identityText(accountArg.email, accountArg.plan);
|
|
1620
|
+
const priorityUntil = accountArg.removed ? null
|
|
1621
|
+
: plugins.authswitchPriority.authSwitchPriorityUntil(accountArg.priorityUntil, contextArg.now);
|
|
1622
|
+
const priority = priorityText(priorityUntil, contextArg.now);
|
|
1596
1623
|
const liftedUntil = !accountArg.removed && accountArg.maxUsagePercent !== null
|
|
1597
1624
|
&& plugins.authswitchUsageLimit.authSwitchReserveLiftActive(accountArg.reserveLiftUntil, contextArg.now)
|
|
1598
1625
|
? accountArg.reserveLiftUntil! : null;
|
|
@@ -1607,6 +1634,8 @@ const serviceRow = (
|
|
|
1607
1634
|
spendLimitMicroUsd: apiKey ? accountArg.spendLimitMicroUsd : null,
|
|
1608
1635
|
claudeCode: accountArg.claudeCode,
|
|
1609
1636
|
renewsAt: claudeSignIn ? accountArg.renewsAt : null,
|
|
1637
|
+
priorityUntil,
|
|
1638
|
+
priorityStatus: priority ? { text: `${priority.charAt(0).toUpperCase()}${priority.slice(1)}`, tone: 'info' } : null,
|
|
1610
1639
|
removeNote: apiKey
|
|
1611
1640
|
? `AGL stops using the key. It stays valid at ${provider.name} until you revoke it in ${provider.console}.`
|
|
1612
1641
|
: '',
|
|
@@ -1663,6 +1692,11 @@ const serviceRow = (
|
|
|
1663
1692
|
? [serviceSlot('liftReserve', 'Lift reserve', 'lucide:Clock', contextArg.service, removed)] : []),
|
|
1664
1693
|
// A renewal is a Claude subscription's: neither a key nor a ChatGPT account has one to set.
|
|
1665
1694
|
...(claudeSignIn ? [serviceSlot('renewal', 'Renewal', 'lucide:CalendarClock', contextArg.service, removed)] : []),
|
|
1695
|
+
// Any account can have priority; giving it again starts its 24 hours again.
|
|
1696
|
+
serviceSlot('priority', priorityUntil === null ? 'Give priority' : 'Restart 24 hours', 'lucide:Star',
|
|
1697
|
+
contextArg.service, removed),
|
|
1698
|
+
...(priorityUntil === null ? []
|
|
1699
|
+
: [serviceSlot('clearPriority', 'Turn off', 'lucide:StarOff', contextArg.service, removed)]),
|
|
1666
1700
|
serviceSlot('remove', 'Remove', 'lucide:Trash2', contextArg.service, removed),
|
|
1667
1701
|
...(usageLogin ? [serviceSlot('usage', 'Show latest usage', 'lucide:Gauge', contextArg.service)] : []),
|
|
1668
1702
|
...(usageLogin && payment ? [serviceSlot('recheck', 'Re-check', 'lucide:RotateCcw', contextArg.service)] : []),
|
|
@@ -1024,6 +1024,22 @@ export class AglAccounts extends plugins.deesElement.DeesElement {
|
|
|
1024
1024
|
});
|
|
1025
1025
|
}
|
|
1026
1026
|
|
|
1027
|
+
/**
|
|
1028
|
+
* Gives the account the owner's priority for 24 hours from now, or turns it off with `false`. The accounts service sets
|
|
1029
|
+
* its end by its own clock; the page shows it in local time once the projection has it.
|
|
1030
|
+
*/
|
|
1031
|
+
private async setPriority(rowArg: IAccountRow, priorityArg: boolean): Promise<void> {
|
|
1032
|
+
await this.runAction(`priority:${rowArg.accountId}`, async () => {
|
|
1033
|
+
const { answer } = await this.client!.fire<interfaces.IReq_ControllerAccountsPriority>(
|
|
1034
|
+
'controller.accounts.priority',
|
|
1035
|
+
{ accountId: rowArg.accountId, expectedRevision: rowArg.revision, priority: priorityArg },
|
|
1036
|
+
{ maxRetries: 0 },
|
|
1037
|
+
);
|
|
1038
|
+
this.notice = answerNotice(answer);
|
|
1039
|
+
await this.refresh();
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1027
1043
|
/** Sets an API key's monthly spend limit from the field, in dollars, or clears it with `null`. */
|
|
1028
1044
|
private async setSpendLimit(rowArg: IAccountRow, spendLimitMicroUsdArg: number | null): Promise<void> {
|
|
1029
1045
|
await this.runAction(`spendlimit:${rowArg.accountId}`, async () => {
|
|
@@ -1075,6 +1091,31 @@ export class AglAccounts extends plugins.deesElement.DeesElement {
|
|
|
1075
1091
|
`;
|
|
1076
1092
|
}
|
|
1077
1093
|
|
|
1094
|
+
/**
|
|
1095
|
+
* The owner's priority (AGL-1809): while it holds, new sessions go to this account before any account of its pool
|
|
1096
|
+
* without one, for 24 hours from when it was given, or until it is turned off. Giving it again starts the 24 hours
|
|
1097
|
+
* again.
|
|
1098
|
+
*/
|
|
1099
|
+
private renderPriority(rowArg: IAccountRow, slotsArg: readonly IAccountActionSlot[]): plugins.deesElement.TemplateResult {
|
|
1100
|
+
return plugins.deesElement.html`
|
|
1101
|
+
<div class="item" data-priority>
|
|
1102
|
+
<div>
|
|
1103
|
+
<div class="itemLabel">Priority</div>
|
|
1104
|
+
<div class="itemText">AGL places new sessions on this account before any other while it takes them, for 24
|
|
1105
|
+
hours or until you turn it off; several accounts can have it. Sessions already running elsewhere stay where
|
|
1106
|
+
they are, and the account's limits still hold.</div>
|
|
1107
|
+
</div>
|
|
1108
|
+
<div class="inline">
|
|
1109
|
+
${rowArg.priorityStatus
|
|
1110
|
+
? plugins.deesElement.html`<dees-badge data-priority-status .type=${badgeType(rowArg.priorityStatus.tone)}
|
|
1111
|
+
.text=${rowArg.priorityStatus.text}></dees-badge>`
|
|
1112
|
+
: ''}
|
|
1113
|
+
${this.slots(slotsArg, (slotArg) => void this.setPriority(rowArg, slotArg.id === 'priority'))}
|
|
1114
|
+
</div>
|
|
1115
|
+
</div>
|
|
1116
|
+
`;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1078
1119
|
/**
|
|
1079
1120
|
* Adds the API key the dialog holds. The accounts service asks the provider whether it accepts the key before it holds
|
|
1080
1121
|
* anything, so the dialog's fields stay locked while it does; added, the dialog closes and the screen says the spend
|
|
@@ -1719,6 +1760,7 @@ export class AglAccounts extends plugins.deesElement.DeesElement {
|
|
|
1719
1760
|
const spendLimitSlot = slot('spendLimit');
|
|
1720
1761
|
const claudeCodeSlot = slot('claudeCode');
|
|
1721
1762
|
const liftSlot = slot('liftReserve');
|
|
1763
|
+
const prioritySlots = [slot('priority'), slot('clearPriority')].filter((slotArg) => slotArg !== null);
|
|
1722
1764
|
const removeSlot = slot('remove');
|
|
1723
1765
|
const useCodexSlot = slot('useCodex');
|
|
1724
1766
|
const releaseCodexSlot = slot('releaseCodex');
|
|
@@ -1845,6 +1887,12 @@ export class AglAccounts extends plugins.deesElement.DeesElement {
|
|
|
1845
1887
|
</div>
|
|
1846
1888
|
</section>`
|
|
1847
1889
|
: ''}
|
|
1890
|
+
${prioritySlots.length
|
|
1891
|
+
? plugins.deesElement.html`<section class="section" data-placement aria-label="Placement">
|
|
1892
|
+
<div class="sectionHead"><span>Placement</span></div>
|
|
1893
|
+
<div class="card">${this.renderPriority(rowArg, prioritySlots)}</div>
|
|
1894
|
+
</section>`
|
|
1895
|
+
: ''}
|
|
1848
1896
|
${rowArg.harnesses.length || rowArg.flexActions.length
|
|
1849
1897
|
? plugins.deesElement.html`<section class="section" data-used-by aria-label="Used by">
|
|
1850
1898
|
<div class="sectionHead"><span>Used by</span></div>
|