@aspectlylabs/mikka 0.0.702 → 0.0.704
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/README.md +48 -7
- package/cli.js +1074 -964
- package/client.js +37 -52
- package/http-link.js +114 -138
- package/login.js +47 -55
- package/main.js +1017 -889
- package/mikka-release-manifest.json +22 -22
- package/mikka.js +1074 -964
- package/npm-shrinkwrap.json +5 -5
- package/package.json +2 -2
- package/paths.js +2 -2
- package/sbom.cdx.json +14 -14
package/login.js
CHANGED
|
@@ -3176,6 +3176,15 @@ var daemonStatusSchema = z15.object({
|
|
|
3176
3176
|
/** Holds a device credential (it may still be refused by the server). */
|
|
3177
3177
|
signedIn: z15.boolean(),
|
|
3178
3178
|
server: z15.enum(["online", "offline", "unregistered"]),
|
|
3179
|
+
/**
|
|
3180
|
+
* The device session (decision 2026-11-17-2215). `update_required`: the
|
|
3181
|
+
* server refused this daemon version; it does nothing until it is updated.
|
|
3182
|
+
* `gateway_required`: the server has no device gateway, so it has no devices.
|
|
3183
|
+
* Absent from older daemons.
|
|
3184
|
+
*/
|
|
3185
|
+
session: z15.enum(["signed_out", "connecting", "open", "update_required", "gateway_required"]).optional(),
|
|
3186
|
+
/** With `update_required`: the oldest version the server accepts, if it said. */
|
|
3187
|
+
requiredVersion: z15.string().max(40).nullable().optional(),
|
|
3179
3188
|
harnesses: z15.array(harnessInfoSchema),
|
|
3180
3189
|
runs: z15.array(runSummarySchema),
|
|
3181
3190
|
/** Bytes used by run worktrees under the daemon's data dir. */
|
|
@@ -4239,69 +4248,48 @@ var deviceRegistered = z24.object({
|
|
|
4239
4248
|
environment: z24.enum(["production", "preview", "dev"]).optional()
|
|
4240
4249
|
}).optional().catch(void 0)
|
|
4241
4250
|
});
|
|
4242
|
-
var
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4251
|
+
var DEVICE_SESSION_HEADER = "x-mikka-device-session";
|
|
4252
|
+
var DEVICE_SESSION_VERSION = 1;
|
|
4253
|
+
var SESSION_LEASE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
4254
|
+
var deviceSessionReportSchema = z24.object({
|
|
4255
|
+
state: z24.enum(["connected", "disconnected"]),
|
|
4256
|
+
/** When the socket opened, or closed (or last answered a ping). */
|
|
4257
|
+
at: isoTime,
|
|
4258
|
+
/** One value per socket; a report for an older socket never overrides a newer one. */
|
|
4259
|
+
socketId: z24.string().regex(/^[A-Za-z0-9_-]{8,64}$/)
|
|
4260
|
+
}).strict();
|
|
4249
4261
|
var stableVersion = z24.string().regex(/^(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})$/);
|
|
4250
4262
|
var daemonVersionsSchema = z24.object({ min: stableVersion, latest: stableVersion.optional() });
|
|
4251
4263
|
var daemonUpdateFailureSchema = z24.object({ version: stableVersion, code: z24.enum(["install_failed", "restart_failed"]), at: isoTime });
|
|
4252
4264
|
var deviceManagementCommand = z24.object({ id: z24.uuid(), kind: z24.enum(["redetect", "restart", "update", "uninstall"]) });
|
|
4253
|
-
var
|
|
4265
|
+
var deviceReportSchema = z24.object({
|
|
4254
4266
|
completedDeviceCommands: z24.array(z24.uuid()).max(100).optional(),
|
|
4255
4267
|
failedDeviceCommands: z24.array(z24.object({ id: z24.uuid(), error: z24.string().max(500) })).max(100).optional(),
|
|
4256
|
-
harnesses: z24.array(harnessInfoSchema).max(20),
|
|
4268
|
+
harnesses: z24.array(harnessInfoSchema).max(20).optional(),
|
|
4257
4269
|
computerUse: deviceComputerCapability.optional(),
|
|
4258
4270
|
runner: deviceRunnerCapability.optional(),
|
|
4259
4271
|
deviceType: z24.enum(["laptop", "server"]).optional(),
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
/**
|
|
4263
|
-
* Subscription windows read on this device. Absent when the daemon is not
|
|
4264
|
-
* polling. Numbers only, never a vendor credential (ADR 0027).
|
|
4265
|
-
*/
|
|
4272
|
+
worktreeDiskBytes: z24.number().int().nonnegative().optional(),
|
|
4273
|
+
/** Subscription windows read on this device. Numbers only, never a vendor credential (ADR 0027). */
|
|
4266
4274
|
quotas: z24.array(quotaSnapshotSchema).max(6).optional(),
|
|
4267
4275
|
/** Null once no automatic update has failed since the last success. */
|
|
4268
|
-
updateFailure: daemonUpdateFailureSchema.nullable().optional()
|
|
4276
|
+
updateFailure: daemonUpdateFailureSchema.nullable().optional(),
|
|
4277
|
+
/** A cloud worker asks for its next token once, an hour before the current one expires. */
|
|
4278
|
+
rotateCloudCredential: z24.literal(true).optional()
|
|
4269
4279
|
});
|
|
4270
|
-
var
|
|
4280
|
+
var deviceReportResultSchema = z24.object({
|
|
4271
4281
|
deviceCommands: z24.array(deviceManagementCommand).max(1).optional(),
|
|
4272
|
-
/** Renewed lease expiry per run id; a run missing here is not renewed. */
|
|
4273
|
-
leases: z24.record(z24.string(), isoTime),
|
|
4274
|
-
/** No plaintext: only grants for current owner/device/run/claim bindings. */
|
|
4275
|
-
taskSecrets: z24.record(z24.string(), taskSecretAccessSchema).optional(),
|
|
4276
|
-
/**
|
|
4277
|
-
* Runs the device reported that it no longer holds: they ended on the
|
|
4278
|
-
* server, or went to another attempt after the lease ran out. The daemon
|
|
4279
|
-
* stops them now instead of when their lease runs out.
|
|
4280
|
-
*/
|
|
4281
|
-
revoked: z24.array(id3).max(500).optional(),
|
|
4282
|
-
/** Subset of revoked caused by an explicit cancel on an otherwise current claim. */
|
|
4283
|
-
cancelled: z24.array(id3).max(500).optional(),
|
|
4284
4282
|
/** Short-lived cloud device token, returned only over its authenticated link. */
|
|
4285
4283
|
cloudCredential: z24.string().regex(/^orv_[A-Za-z0-9_-]{43}$/).optional(),
|
|
4286
|
-
|
|
4284
|
+
cloudCredentialExpiresAt: isoTime.optional(),
|
|
4285
|
+
/** A malformed value is dropped, never a failed report. */
|
|
4287
4286
|
daemonVersions: daemonVersionsSchema.optional().catch(void 0)
|
|
4288
4287
|
});
|
|
4289
4288
|
var deviceGatewaySchema = z24.object({
|
|
4290
|
-
url: z24.string().url()
|
|
4291
|
-
protocol: z24.string().regex(/^mikka-ticket-[0-9]+-[a-f0-9]{64}$/)
|
|
4292
|
-
/**
|
|
4293
|
-
|
|
4294
|
-
* connected daemon needs no periodic run-control check (#1212). Absent from
|
|
4295
|
-
* older servers: the daemon then keeps its one-second check. */
|
|
4296
|
-
runControl: z24.literal("push").optional(),
|
|
4297
|
-
/** This server wakes the device when a person decides a computer review in
|
|
4298
|
-
* the web, so a connected daemon syncs pending reviews only on a change or a
|
|
4299
|
-
* push, plus a presence refresh (#1212). Absent from older servers: the
|
|
4300
|
-
* daemon then keeps syncing every second while a review is pending. */
|
|
4301
|
-
computerReviews: z24.literal("push").optional(),
|
|
4302
|
-
/** This server wakes the device when it writes a native Coordinator tool
|
|
4303
|
-
* result, so the waiting tool asks once per push, not every 500 ms. */
|
|
4304
|
-
coordinatorResults: z24.literal("push").optional()
|
|
4289
|
+
url: z24.string().url(),
|
|
4290
|
+
protocol: z24.string().regex(/^mikka-ticket-[0-9]+-[a-f0-9]{64}$/),
|
|
4291
|
+
/** Cloud workers only: when the current device token expires. */
|
|
4292
|
+
cloudCredentialExpiresAt: isoTime.optional()
|
|
4305
4293
|
});
|
|
4306
4294
|
var RUN_CHECKPOINT_MAX_BYTES = 8 * 1024 * 1024;
|
|
4307
4295
|
var RUN_CHECKPOINT_RECOVERY_MAX_AGE_MS = 30 * 6e4;
|
|
@@ -4454,7 +4442,7 @@ var runAssignmentSchema = z24.object({
|
|
|
4454
4442
|
/** Host-owned Factory check mode; the model cannot grant a check or skip verification. */
|
|
4455
4443
|
factoryCheck: z24.object({ stage: z24.enum(["review", "verify"]), inferCommand: z24.boolean(), reportOnly: z24.boolean() }).strict().optional(),
|
|
4456
4444
|
factoryExecuteKind: z24.enum(["repository", "report", "deliverable"]).optional(),
|
|
4457
|
-
/** Run lease
|
|
4445
|
+
/** Run lease in the database: it lasts as long as the device session that claimed the run. */
|
|
4458
4446
|
leaseExpiresAt: isoTime.optional(),
|
|
4459
4447
|
/**
|
|
4460
4448
|
* The Mikka MCP server for the agent inside this run: `report`, `ask` and
|
|
@@ -4607,14 +4595,13 @@ var runCommandsResponse = z24.object({
|
|
|
4607
4595
|
/** Owner-scoped reads, delivered only to a daemon advertising protocol v1. */
|
|
4608
4596
|
workspaceRequests: z24.array(workspaceReadCommand).max(4).optional(),
|
|
4609
4597
|
/**
|
|
4610
|
-
* Runs queued for this device (outside `skip`), so it claims them
|
|
4611
|
-
*
|
|
4612
|
-
* Absent from older servers; the heartbeat still claims either way.
|
|
4598
|
+
* Runs queued for this device (outside `skip`), so it claims them as soon
|
|
4599
|
+
* as the gateway signals work.
|
|
4613
4600
|
*/
|
|
4614
4601
|
queuedRuns: z24.array(id3).max(100).optional(),
|
|
4615
4602
|
/** Only for a daemon that sent `COMMANDS_DAEMON_LATEST_PARAM`; a malformed value is dropped. */
|
|
4616
4603
|
daemonVersions: daemonVersionsSchema.optional().catch(void 0),
|
|
4617
|
-
/** The oldest pending device command
|
|
4604
|
+
/** The oldest pending device command, so a person's update reaches the device now. */
|
|
4618
4605
|
deviceCommands: z24.array(deviceManagementCommand).max(1).optional().catch(void 0)
|
|
4619
4606
|
});
|
|
4620
4607
|
var runCommandsAck = z24.object({
|
|
@@ -5164,7 +5151,7 @@ var ServerUnreachableError = class extends DaemonError {
|
|
|
5164
5151
|
// package.json
|
|
5165
5152
|
var package_default = {
|
|
5166
5153
|
name: "@mikka/daemon",
|
|
5167
|
-
version: "0.0.
|
|
5154
|
+
version: "0.0.704",
|
|
5168
5155
|
description: "Local Mikka daemon: runs agents through the user's own CLIs",
|
|
5169
5156
|
type: "module",
|
|
5170
5157
|
private: true,
|
|
@@ -5232,7 +5219,7 @@ var package_default = {
|
|
|
5232
5219
|
engines: {
|
|
5233
5220
|
node: ">=22"
|
|
5234
5221
|
},
|
|
5235
|
-
gitHead: "
|
|
5222
|
+
gitHead: "a5c45e4d686a337f5dd0ea0acbac2e1e70aa9e03"
|
|
5236
5223
|
};
|
|
5237
5224
|
|
|
5238
5225
|
// src/paths.ts
|
|
@@ -6510,7 +6497,7 @@ var RunRuntimeTimings = class {
|
|
|
6510
6497
|
if (!observation2 || observation2.deviceHash !== runIdHash(decodeURIComponent(github[1]))) return NOOP2;
|
|
6511
6498
|
return observation2.request(this.refresh.getStore() === hash2 ? "github_credential_refresh" : "github_credential_lease", verb, false);
|
|
6512
6499
|
}
|
|
6513
|
-
const device = /^\/v1\/devices\/([^/]+)\/(
|
|
6500
|
+
const device = /^\/v1\/devices\/([^/]+)\/(report|gateway|commands|runs)$/.exec(clean);
|
|
6514
6501
|
if (!device) return NOOP2;
|
|
6515
6502
|
const hash = runIdHash(decodeURIComponent(device[1]));
|
|
6516
6503
|
const pending = [...this.runs.values()].filter((observation2) => observation2.deviceHash === hash).map((observation2) => observation2.request("device_control", verb, true));
|
|
@@ -6526,11 +6513,13 @@ var runRuntimeTimings = new RunRuntimeTimings();
|
|
|
6526
6513
|
|
|
6527
6514
|
// src/server-link-http.ts
|
|
6528
6515
|
var deviceSessionRejection = z35.object({ error: z35.enum(["Unauthorized", "authRequired"]) }).strict();
|
|
6516
|
+
var deviceSessionHeaders = { [DEVICE_SESSION_HEADER]: String(DEVICE_SESSION_VERSION) };
|
|
6529
6517
|
function serverUrl(base, path3) {
|
|
6530
6518
|
return new URL(`${base.replace(/\/+$/, "")}${path3}`);
|
|
6531
6519
|
}
|
|
6532
6520
|
|
|
6533
6521
|
// src/login.ts
|
|
6522
|
+
var updateRequired = () => new LoginError("failed", "This daemon is too old for the server. Update it first: npm install -g @aspectlylabs/mikka@latest");
|
|
6534
6523
|
var DEVICE_CODE_PATH = `${AUTH_BASE_PATH}/device/code`;
|
|
6535
6524
|
var DEVICE_TOKEN_PATH = `${AUTH_BASE_PATH}/device/token`;
|
|
6536
6525
|
var DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
@@ -6559,7 +6548,8 @@ async function post(options, path3, body) {
|
|
|
6559
6548
|
method: "POST",
|
|
6560
6549
|
headers: {
|
|
6561
6550
|
"content-type": "application/json",
|
|
6562
|
-
[CLIENT_VERSION_HEADER]: DAEMON_VERSION
|
|
6551
|
+
[CLIENT_VERSION_HEADER]: DAEMON_VERSION,
|
|
6552
|
+
...deviceSessionHeaders
|
|
6563
6553
|
},
|
|
6564
6554
|
body: JSON.stringify(body),
|
|
6565
6555
|
signal: options.signal
|
|
@@ -6567,6 +6557,7 @@ async function post(options, path3, body) {
|
|
|
6567
6557
|
} catch (error) {
|
|
6568
6558
|
throw new ServerUnreachableError(error);
|
|
6569
6559
|
}
|
|
6560
|
+
if (response.status === 426) throw updateRequired();
|
|
6570
6561
|
return {
|
|
6571
6562
|
status: response.status,
|
|
6572
6563
|
json: await response.json().catch(() => null)
|
|
@@ -6625,10 +6616,11 @@ async function registrationLogin(options) {
|
|
|
6625
6616
|
if (!/^orv_[A-Za-z0-9_-]{43}$/.test(options.token)) throw new LoginError("failed", "Invalid registration token.");
|
|
6626
6617
|
const response = await (options.fetchImpl ?? fetch)(serverUrl(options.serverUrl, "/v1/devices/enroll"), {
|
|
6627
6618
|
method: "POST",
|
|
6628
|
-
headers: { authorization: `Bearer ${options.token}
|
|
6619
|
+
headers: { authorization: `Bearer ${options.token}`, [CLIENT_VERSION_HEADER]: DAEMON_VERSION, ...deviceSessionHeaders },
|
|
6629
6620
|
redirect: "error",
|
|
6630
6621
|
signal: AbortSignal.timeout(3e4)
|
|
6631
6622
|
});
|
|
6623
|
+
if (response.status === 426) throw updateRequired();
|
|
6632
6624
|
const body = await response.json().catch(() => null);
|
|
6633
6625
|
const parsed = tokenResponse.safeParse({ access_token: body?.credential });
|
|
6634
6626
|
if (!response.ok || !parsed.success) throw new LoginError("failed", "Device registration token expired or already used.");
|