@m8t-stack/cli 0.2.111 → 0.2.113
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.js +94 -12
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1454,7 +1454,7 @@ function installFoundryDnsShim() {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
|
|
1456
1456
|
// src/lib/package-version.ts
|
|
1457
|
-
var CLI_VERSION = "0.2.
|
|
1457
|
+
var CLI_VERSION = "0.2.113";
|
|
1458
1458
|
|
|
1459
1459
|
// src/lib/render-error.ts
|
|
1460
1460
|
init_errors();
|
|
@@ -28700,7 +28700,7 @@ var OpenCommand = class extends M8tCommand {
|
|
|
28700
28700
|
// src/commands/dream/run.ts
|
|
28701
28701
|
import { Command as Command55, Option as Option52 } from "clipanion";
|
|
28702
28702
|
import { AzureCliCredential } from "@azure/identity";
|
|
28703
|
-
import { TableClient as
|
|
28703
|
+
import { TableClient as TableClient8 } from "@azure/data-tables";
|
|
28704
28704
|
import { AIProjectClient as AIProjectClient3 } from "@azure/ai-projects";
|
|
28705
28705
|
import { LogsQueryClient as LogsQueryClient3, LogsQueryResultStatus as LogsQueryResultStatus3 } from "@azure/monitor-query";
|
|
28706
28706
|
|
|
@@ -31125,6 +31125,64 @@ async function resolveDreamContext(opts) {
|
|
|
31125
31125
|
init_esm2();
|
|
31126
31126
|
init_esm();
|
|
31127
31127
|
init_foundry_agent_get();
|
|
31128
|
+
|
|
31129
|
+
// src/lib/dream-cursor-write-preflight.ts
|
|
31130
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
31131
|
+
import { TableClient as TableClient7 } from "@azure/data-tables";
|
|
31132
|
+
var PROBE_PARTITION_PREFIX = "__m8t_dream_cursor_write_preflight__";
|
|
31133
|
+
var NONMATCHING_TABLE_ETAG = `W/"datetime'1970-01-01T00%3A00%3A00.0000000Z'"`;
|
|
31134
|
+
function serviceCode(error) {
|
|
31135
|
+
const candidate2 = error;
|
|
31136
|
+
return {
|
|
31137
|
+
statusCode: candidate2.statusCode,
|
|
31138
|
+
code: candidate2.code ?? candidate2.details?.errorCode,
|
|
31139
|
+
message: candidate2.message
|
|
31140
|
+
};
|
|
31141
|
+
}
|
|
31142
|
+
function isTableAlreadyExists(error) {
|
|
31143
|
+
const { statusCode, code } = serviceCode(error);
|
|
31144
|
+
return statusCode === 409 && code === "TableAlreadyExists";
|
|
31145
|
+
}
|
|
31146
|
+
function provesAuthorizedNonMutation(error) {
|
|
31147
|
+
const { statusCode, code, message } = serviceCode(error);
|
|
31148
|
+
if (!message?.startsWith("1:")) return false;
|
|
31149
|
+
return statusCode === 404 && (code === "EntityNotFound" || code === "ResourceNotFound") || statusCode === 412 && code === "UpdateConditionNotSatisfied";
|
|
31150
|
+
}
|
|
31151
|
+
async function preflightDreamCursorWrite(client, uuid = randomUUID2) {
|
|
31152
|
+
try {
|
|
31153
|
+
await client.createTable();
|
|
31154
|
+
} catch (error) {
|
|
31155
|
+
if (!isTableAlreadyExists(error)) throw error;
|
|
31156
|
+
}
|
|
31157
|
+
const attempt = uuid();
|
|
31158
|
+
const partitionKey = `${PROBE_PARTITION_PREFIX}-${attempt}`;
|
|
31159
|
+
const actions = [
|
|
31160
|
+
[
|
|
31161
|
+
"upsert",
|
|
31162
|
+
{ partitionKey, rowKey: `upsert-${attempt}`, proof: "authorization-only" },
|
|
31163
|
+
"Replace"
|
|
31164
|
+
],
|
|
31165
|
+
[
|
|
31166
|
+
"update",
|
|
31167
|
+
{ partitionKey, rowKey: `abort-${attempt}`, proof: "atomic-rollback" },
|
|
31168
|
+
"Merge",
|
|
31169
|
+
{ etag: NONMATCHING_TABLE_ETAG }
|
|
31170
|
+
]
|
|
31171
|
+
];
|
|
31172
|
+
try {
|
|
31173
|
+
await client.submitTransaction(actions);
|
|
31174
|
+
} catch (error) {
|
|
31175
|
+
if (provesAuthorizedNonMutation(error)) return;
|
|
31176
|
+
throw error;
|
|
31177
|
+
}
|
|
31178
|
+
throw new Error("Dream cursor write preflight transaction unexpectedly committed.");
|
|
31179
|
+
}
|
|
31180
|
+
async function preflightDreamCursorWriteAt(tableEndpoint, credential2) {
|
|
31181
|
+
const client = new TableClient7(tableEndpoint, CURSOR_TABLE_NAME, credential2);
|
|
31182
|
+
await preflightDreamCursorWrite(client);
|
|
31183
|
+
}
|
|
31184
|
+
|
|
31185
|
+
// src/commands/dream/run.ts
|
|
31128
31186
|
var LEDGER_TABLE_NAME = "AgentLedger";
|
|
31129
31187
|
var SAFE_ID2 = /^[A-Za-z0-9_]+$/;
|
|
31130
31188
|
var CONV_ID2 = /^conv_[A-Za-z0-9]+$/;
|
|
@@ -31198,6 +31256,7 @@ var DreamRunCommand = class extends M8tCommand {
|
|
|
31198
31256
|
endpoint: typeof this.endpoint === "string" ? this.endpoint : void 0,
|
|
31199
31257
|
storageAccount: typeof this.storageAccount === "string" ? this.storageAccount : void 0
|
|
31200
31258
|
});
|
|
31259
|
+
await liveDeps.preflightCursorWrite();
|
|
31201
31260
|
const liveCursor = await liveDeps.readCursor(liveContext.worker);
|
|
31202
31261
|
const result2 = await liveDeps.runDream({
|
|
31203
31262
|
worker: liveContext.worker,
|
|
@@ -31375,7 +31434,7 @@ AppDependencies
|
|
|
31375
31434
|
};
|
|
31376
31435
|
}
|
|
31377
31436
|
function buildLiveSources(context, credential2) {
|
|
31378
|
-
const ledgerClient = new
|
|
31437
|
+
const ledgerClient = new TableClient8(context.ledgerTableEndpoint, LEDGER_TABLE_NAME, credential2);
|
|
31379
31438
|
const ledger = makeLedgerSource(
|
|
31380
31439
|
async (pk, sinceTs) => fetchLedgerRows(
|
|
31381
31440
|
{ workers: [pk], source: "all", from: sinceTs, to: "9999-12-31T23:59:59.999Z" },
|
|
@@ -31490,6 +31549,29 @@ function defaultDeps(overrides) {
|
|
|
31490
31549
|
}
|
|
31491
31550
|
});
|
|
31492
31551
|
},
|
|
31552
|
+
async preflightCursorWrite() {
|
|
31553
|
+
if (!cached) {
|
|
31554
|
+
throw new LocalCliError({
|
|
31555
|
+
code: "DREAM_INTERNAL",
|
|
31556
|
+
message: "preflightCursorWrite called before resolveContext."
|
|
31557
|
+
});
|
|
31558
|
+
}
|
|
31559
|
+
try {
|
|
31560
|
+
if (overrides?.preflightCursorWrite) {
|
|
31561
|
+
await overrides.preflightCursorWrite(cached.context, credential2);
|
|
31562
|
+
} else {
|
|
31563
|
+
await preflightDreamCursorWriteAt(cached.context.ledgerTableEndpoint, credential2);
|
|
31564
|
+
}
|
|
31565
|
+
} catch (cause) {
|
|
31566
|
+
if (cause.statusCode !== 403) throw cause;
|
|
31567
|
+
throw new LocalCliError({
|
|
31568
|
+
code: "DREAM_CURSOR_WRITE_REQUIRED",
|
|
31569
|
+
message: `Cannot write the dream cursor for worker '${cached.context.worker}'. The live dream was not started.`,
|
|
31570
|
+
hint: "Grant the signed-in operator Storage Table Data Contributor on the ledger storage account, then retry.",
|
|
31571
|
+
cause
|
|
31572
|
+
});
|
|
31573
|
+
}
|
|
31574
|
+
},
|
|
31493
31575
|
async readCursor(worker) {
|
|
31494
31576
|
if (!cached) {
|
|
31495
31577
|
throw new LocalCliError({
|
|
@@ -31531,7 +31613,7 @@ function defaultDeps(overrides) {
|
|
|
31531
31613
|
import { createHash as createHash5 } from "crypto";
|
|
31532
31614
|
import { Command as Command56, Option as Option53 } from "clipanion";
|
|
31533
31615
|
import { AzureCliCredential as AzureCliCredential2 } from "@azure/identity";
|
|
31534
|
-
import { TableClient as
|
|
31616
|
+
import { TableClient as TableClient9 } from "@azure/data-tables";
|
|
31535
31617
|
import { AIProjectClient as AIProjectClient4 } from "@azure/ai-projects";
|
|
31536
31618
|
init_errors();
|
|
31537
31619
|
var LEDGER_TABLE_NAME2 = "AgentLedger";
|
|
@@ -31600,7 +31682,7 @@ function defaultDeps2() {
|
|
|
31600
31682
|
return { projectEndpoint: project.endpoint, ledgerTableEndpoint };
|
|
31601
31683
|
},
|
|
31602
31684
|
async fetchRows(ctx, fromIso, toIso) {
|
|
31603
|
-
const client = new
|
|
31685
|
+
const client = new TableClient9(ctx.ledgerTableEndpoint, LEDGER_TABLE_NAME2, credential2);
|
|
31604
31686
|
try {
|
|
31605
31687
|
return await fetchLedgerRows({ workers: [], source: "all", from: fromIso, to: toIso }, client);
|
|
31606
31688
|
} catch (e) {
|
|
@@ -32509,7 +32591,7 @@ async function kickInstaller(s) {
|
|
|
32509
32591
|
}
|
|
32510
32592
|
|
|
32511
32593
|
// src/lib/bootstrap-status.ts
|
|
32512
|
-
import { createHash as createHash7, randomUUID as
|
|
32594
|
+
import { createHash as createHash7, randomUUID as randomUUID3 } from "crypto";
|
|
32513
32595
|
import * as fs32 from "fs/promises";
|
|
32514
32596
|
import * as os13 from "os";
|
|
32515
32597
|
import * as path35 from "path";
|
|
@@ -32551,7 +32633,7 @@ async function readStatusBlob(opts) {
|
|
|
32551
32633
|
cause: e
|
|
32552
32634
|
});
|
|
32553
32635
|
}
|
|
32554
|
-
const tmpFile = path35.join(os13.tmpdir(), `m8t-status-${
|
|
32636
|
+
const tmpFile = path35.join(os13.tmpdir(), `m8t-status-${randomUUID3()}.json`);
|
|
32555
32637
|
try {
|
|
32556
32638
|
await runAz([
|
|
32557
32639
|
"storage",
|
|
@@ -32719,7 +32801,7 @@ ${colors.error("\u2717")} The GitHub App on disk is installed on ${colors.field(
|
|
|
32719
32801
|
// src/commands/bootstrap/launch.ts
|
|
32720
32802
|
var DEFAULT_RG = "rg-m8t-stack";
|
|
32721
32803
|
var DEFAULT_INSTALLER = "ghcr.io/m8t-labs/m8t-installer";
|
|
32722
|
-
var DEFAULT_INSTALLER_TAG = "v0.1.
|
|
32804
|
+
var DEFAULT_INSTALLER_TAG = "v0.1.80";
|
|
32723
32805
|
var ACI_NAME = "m8t-installer";
|
|
32724
32806
|
var MI_NAME = "m8t-installer-mi";
|
|
32725
32807
|
var BootstrapLaunchCommand = class extends M8tCommand {
|
|
@@ -33904,7 +33986,7 @@ function renderInstallSummary(args) {
|
|
|
33904
33986
|
import { constants as constants2 } from "fs";
|
|
33905
33987
|
import * as fs38 from "fs/promises";
|
|
33906
33988
|
import * as path42 from "path";
|
|
33907
|
-
import { randomUUID as
|
|
33989
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
33908
33990
|
import { execFile as execFile2, spawn as spawn7 } from "child_process";
|
|
33909
33991
|
|
|
33910
33992
|
// src/lib/companion-artifact.ts
|
|
@@ -34741,7 +34823,7 @@ async function atomicWriteText(filePath, contents, mode) {
|
|
|
34741
34823
|
recursive: true,
|
|
34742
34824
|
mode: 448
|
|
34743
34825
|
});
|
|
34744
|
-
const temporary = `${filePath}.${
|
|
34826
|
+
const temporary = `${filePath}.${randomUUID4()}.tmp`;
|
|
34745
34827
|
try {
|
|
34746
34828
|
await fs38.writeFile(temporary, contents, {
|
|
34747
34829
|
mode,
|
|
@@ -34939,8 +35021,8 @@ async function converge(options, force) {
|
|
|
34939
35021
|
if (error.code !== "ENOENT") throw error;
|
|
34940
35022
|
}
|
|
34941
35023
|
}
|
|
34942
|
-
const stage = `${paths.targetRoot}.m8t-stage-${
|
|
34943
|
-
const backup = `${paths.targetRoot}.m8t-backup-${
|
|
35024
|
+
const stage = `${paths.targetRoot}.m8t-stage-${randomUUID4()}`;
|
|
35025
|
+
const backup = `${paths.targetRoot}.m8t-backup-${randomUUID4()}`;
|
|
34944
35026
|
const copy = options.copyPayload ?? copyArtifactPayload;
|
|
34945
35027
|
await fs38.mkdir(path42.dirname(paths.targetRoot), {
|
|
34946
35028
|
recursive: true,
|