@moxxy/cli 0.40.0 → 0.41.1
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/bin.js +1795 -686
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -8,12 +8,14 @@ import path3__default, { join, dirname, resolve, relative, isAbsolute, posix, se
|
|
|
8
8
|
import { ensurePrivateDir, moxxyHome, pruneStaleTempFiles, moxxyPath, hasProxy, installEgressProxy, readProxyEnv, writeFileAtomic, ensurePrivateFile, resolveChannelToken, rotateChannelToken, liveChannelStatus, spawnDedicatedChannel, stopDedicatedChannel, clearChannelStatus, MOXXY_WS_SUBPROTOCOL, bearerTokenMatches, PRIVATE_FILE_MODE, bearerGuard, tokenFromWsProtocolHeader, resolveOsPrincipal, redactProxyUrl, resolveExecutableTarget, spawnExecutableTarget, listLiveChannelStatuses, writeSignedNetworkCacheAtomic, CrossProcessFireLock, writeChannelStatus, writeBoundedNetworkCacheAtomicSync, writeBoundedDataCacheAtomic, readRequestBody } from '@moxxy/sdk/server';
|
|
9
9
|
import { spawn, execFile, spawnSync } from 'child_process';
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
11
|
-
import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, defineTool, defineCommand, defineEmbedder, asPluginId, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeWithProvider, toolResultBytes, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computeElisionState, toolResultStubbed, toolResultStub, conversationalStubbed, conversationalStub, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, moxxyPackageSchema, auditActionOf, verifyEd25519, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName,
|
|
11
|
+
import { MoxxyError, createMutex, defineMode, definePlugin, defineChannel, defineViewRenderer, DEFAULT_VIEW_TAGS, defineTunnelProvider, defineAuditExporter, defineAuditSink, z as z$1, defineTool, defineCommand, defineEmbedder, asPluginId, runReactLoop, createDeferredPermissionResolver, isSafeViewUrl, redactSecrets, asTurnId, defineCompactor, abortError, activeCompactionRanges, defineCacheStrategy, denyByDefaultResolver, runManualCompaction, assertDefined, defineWorkflowExecutor, MOXXY_PCM16_24KHZ_MIME, isFileDiffDisplay, summarizeWithProvider, toolResultBytes, isSelectableMode, summarizeSessionTokensFromEvents, summarizeTokensByModel, getInstallHint, toDiffRows, diffGutterNo, fileDiffVerb, fileDiffSummary, computerControlCommandSchema, computeElisionState, toolResultStubbed, toolResultStub, conversationalStubbed, conversationalStub, isFirstPartyPackage, REDACTED_PLACEHOLDER, isSecretKey, addModelTotals, skillFrontmatterSchema, asSkillId, parseFrontmatter, createCallbackResolver, createAllowListResolver, countNodes, autoAllowResolver, SESSION_SOURCES, startChannelWith, EXIT_AFTER_PAIR_FLAG, renderFrontmatter, formatPrincipal, aggregateCapabilitySpecs, hostCredentialName, moxxyPackageSchema, auditActionOf, asToolCallId, dispatchToolCall, verifyEd25519, defineSecretProvider, encodeLoginAuthUrl, redactSecretText, encodeLoginPrompt, ISOLATION_RANK, sleepWithAbort, asSessionId, migrateModeName, parseFrontmatterFile, createJsonFileStore, computerControlSnapshotSchema, computerApprovalFocusSchema, workflowApprovalItemsSchema, evaluateToolRule, asEventId } from '@moxxy/sdk';
|
|
12
12
|
import * as os from 'os';
|
|
13
13
|
import os__default, { homedir, tmpdir, userInfo } from 'os';
|
|
14
14
|
import { createRequire as createRequire$1 } from 'module';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
-
import {
|
|
16
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
17
|
+
import { readFile, realpath, rm, mkdtemp, writeFile, mkdir, open, readdir, unlink, link, rename, stat, access, constants as constants$2 } from 'fs/promises';
|
|
18
|
+
import { setTimeout as setTimeout$1 } from 'timers/promises';
|
|
17
19
|
import { promisify, stripVTControlCharacters } from 'util';
|
|
18
20
|
import * as readline from 'readline/promises';
|
|
19
21
|
import { createServer } from 'http';
|
|
@@ -21,7 +23,6 @@ import net2, { createConnection, connect } from 'net';
|
|
|
21
23
|
import { Worker } from 'worker_threads';
|
|
22
24
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
23
25
|
import { StringDecoder } from 'string_decoder';
|
|
24
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
25
26
|
import N2, { env, cwd, stdout, stdin } from 'process';
|
|
26
27
|
import { Stream, PassThrough } from 'stream';
|
|
27
28
|
import tty, { ReadStream } from 'tty';
|
|
@@ -6598,14 +6599,14 @@ var init_jsonl_event_store = __esm({
|
|
|
6598
6599
|
init_persistence();
|
|
6599
6600
|
jsonlEventStore = {
|
|
6600
6601
|
name: "jsonl",
|
|
6601
|
-
open(
|
|
6602
|
+
open(scope2) {
|
|
6602
6603
|
return new SessionPersistence({
|
|
6603
|
-
sessionId:
|
|
6604
|
-
cwd:
|
|
6605
|
-
...
|
|
6606
|
-
...
|
|
6607
|
-
...
|
|
6608
|
-
...
|
|
6604
|
+
sessionId: scope2.sessionId,
|
|
6605
|
+
cwd: scope2.cwd,
|
|
6606
|
+
...scope2.dir ? { dir: scope2.dir } : {},
|
|
6607
|
+
...scope2.providerName ? { providerName: scope2.providerName } : {},
|
|
6608
|
+
...scope2.modelId ? { modelId: scope2.modelId } : {},
|
|
6609
|
+
...scope2.source ? { source: scope2.source } : {}
|
|
6609
6610
|
});
|
|
6610
6611
|
},
|
|
6611
6612
|
restore: (sessionId, dir) => restoreEvents(sessionId, dir),
|
|
@@ -7070,6 +7071,18 @@ var init_resolvers = __esm({
|
|
|
7070
7071
|
"../core/dist/permissions/resolvers.js"() {
|
|
7071
7072
|
}
|
|
7072
7073
|
});
|
|
7074
|
+
function withPermissionScope(resolver, run2) {
|
|
7075
|
+
return scope.run(resolver, run2);
|
|
7076
|
+
}
|
|
7077
|
+
function currentPermissionScope() {
|
|
7078
|
+
return scope.getStore();
|
|
7079
|
+
}
|
|
7080
|
+
var scope;
|
|
7081
|
+
var init_scope = __esm({
|
|
7082
|
+
"../core/dist/permissions/scope.js"() {
|
|
7083
|
+
scope = new AsyncLocalStorage();
|
|
7084
|
+
}
|
|
7085
|
+
});
|
|
7073
7086
|
function wrapWithPolicy(inner, engine, getToolRule, cwd2) {
|
|
7074
7087
|
const policyDecision = async (call) => {
|
|
7075
7088
|
const policy = engine.check(call);
|
|
@@ -7084,12 +7097,21 @@ function wrapWithPolicy(inner, engine, getToolRule, cwd2) {
|
|
|
7084
7097
|
const decided = await policyDecision(call);
|
|
7085
7098
|
if (decided)
|
|
7086
7099
|
return decided;
|
|
7087
|
-
return target.check(call, ctx);
|
|
7100
|
+
return (currentPermissionScope() ?? target).check(call, ctx);
|
|
7088
7101
|
};
|
|
7089
7102
|
}
|
|
7090
7103
|
if (prop === "policyCheck") {
|
|
7091
7104
|
return async (call) => policyDecision(call);
|
|
7092
7105
|
}
|
|
7106
|
+
if (prop === "mandatoryCheck") {
|
|
7107
|
+
return async (call, ctx) => {
|
|
7108
|
+
const scoped = currentPermissionScope();
|
|
7109
|
+
if (!scoped)
|
|
7110
|
+
return null;
|
|
7111
|
+
const policy = await policyDecision(call);
|
|
7112
|
+
return policy ?? scoped.check(call, ctx);
|
|
7113
|
+
};
|
|
7114
|
+
}
|
|
7093
7115
|
return Reflect.get(target, prop, receiver);
|
|
7094
7116
|
}
|
|
7095
7117
|
});
|
|
@@ -7103,8 +7125,8 @@ async function evaluateWorkspaceToolRule(rule, call, cwd2) {
|
|
|
7103
7125
|
return evaluateToolRule(unscopedRule, call);
|
|
7104
7126
|
}
|
|
7105
7127
|
async function pathsStayInWorkspace(rule, call, cwd2) {
|
|
7106
|
-
const
|
|
7107
|
-
if (!
|
|
7128
|
+
const scope2 = rule.workspace;
|
|
7129
|
+
if (!scope2)
|
|
7108
7130
|
return true;
|
|
7109
7131
|
const input = isRecord(call.input) ? call.input : {};
|
|
7110
7132
|
let workspace;
|
|
@@ -7113,7 +7135,7 @@ async function pathsStayInWorkspace(rule, call, cwd2) {
|
|
|
7113
7135
|
} catch {
|
|
7114
7136
|
return false;
|
|
7115
7137
|
}
|
|
7116
|
-
for (const pathInput of
|
|
7138
|
+
for (const pathInput of scope2.pathInputs) {
|
|
7117
7139
|
const value2 = input[pathInput.key];
|
|
7118
7140
|
if (value2 === void 0 && pathInput.defaultToWorkspace)
|
|
7119
7141
|
continue;
|
|
@@ -7173,6 +7195,7 @@ var init_session = __esm({
|
|
|
7173
7195
|
init_requirements();
|
|
7174
7196
|
init_engine();
|
|
7175
7197
|
init_resolvers();
|
|
7198
|
+
init_scope();
|
|
7176
7199
|
init_logger();
|
|
7177
7200
|
init_registry();
|
|
7178
7201
|
Session = class {
|
|
@@ -7446,8 +7469,8 @@ var init_session = __esm({
|
|
|
7446
7469
|
this.log.clear();
|
|
7447
7470
|
}
|
|
7448
7471
|
/**
|
|
7449
|
-
* Graceful shutdown:
|
|
7450
|
-
*
|
|
7472
|
+
* Graceful shutdown: cancel in-flight work before awaiting plugin shutdown
|
|
7473
|
+
* hooks. Idempotent — safe to call multiple times (subsequent
|
|
7451
7474
|
* calls are no-ops once `closed` is set).
|
|
7452
7475
|
*
|
|
7453
7476
|
* Channels' SIGINT handlers should call this before exiting so plugins
|
|
@@ -7457,6 +7480,7 @@ var init_session = __esm({
|
|
|
7457
7480
|
if (this.closed)
|
|
7458
7481
|
return;
|
|
7459
7482
|
this.closed = true;
|
|
7483
|
+
this.abort(reason);
|
|
7460
7484
|
try {
|
|
7461
7485
|
try {
|
|
7462
7486
|
await this.surfaces.closeAll();
|
|
@@ -7490,6 +7514,9 @@ var init_session = __esm({
|
|
|
7490
7514
|
get providerAdmin() {
|
|
7491
7515
|
return this.services.get("providerAdmin");
|
|
7492
7516
|
}
|
|
7517
|
+
get computerControl() {
|
|
7518
|
+
return this.services.get("computerControl");
|
|
7519
|
+
}
|
|
7493
7520
|
/**
|
|
7494
7521
|
* The MCP-admin capability (enable/detach/list MCP servers), read by the
|
|
7495
7522
|
* runner's mcp handlers + the desktop. @moxxy/plugin-mcp publishes it on the
|
|
@@ -7595,6 +7622,347 @@ var init_session = __esm({
|
|
|
7595
7622
|
};
|
|
7596
7623
|
}
|
|
7597
7624
|
});
|
|
7625
|
+
function createWorkflowToolRunner(session, turnId, subagents) {
|
|
7626
|
+
return {
|
|
7627
|
+
get: (name) => session.tools.get(name),
|
|
7628
|
+
async execute(name, input, signal) {
|
|
7629
|
+
signal.throwIfAborted();
|
|
7630
|
+
const id = randomUUID();
|
|
7631
|
+
await session.log.append({
|
|
7632
|
+
type: "tool_call_requested",
|
|
7633
|
+
sessionId: session.id,
|
|
7634
|
+
turnId,
|
|
7635
|
+
source: "system",
|
|
7636
|
+
callId: asToolCallId(id),
|
|
7637
|
+
name,
|
|
7638
|
+
input
|
|
7639
|
+
});
|
|
7640
|
+
let output;
|
|
7641
|
+
let error;
|
|
7642
|
+
let received = false;
|
|
7643
|
+
const app = session.appContext();
|
|
7644
|
+
for await (const event of dispatchToolCall({
|
|
7645
|
+
sessionId: session.id,
|
|
7646
|
+
turnId,
|
|
7647
|
+
cwd: app.cwd,
|
|
7648
|
+
env: app.env,
|
|
7649
|
+
services: app.services,
|
|
7650
|
+
log: session.log,
|
|
7651
|
+
hooks: session.dispatcher,
|
|
7652
|
+
permissions: session.resolver,
|
|
7653
|
+
tools: session.tools,
|
|
7654
|
+
signal,
|
|
7655
|
+
subagents,
|
|
7656
|
+
emit: (event2) => session.log.append(event2)
|
|
7657
|
+
}, { id, name, input }, 0)) {
|
|
7658
|
+
if (event.type !== "tool_result" || event.callId !== id)
|
|
7659
|
+
continue;
|
|
7660
|
+
received = true;
|
|
7661
|
+
if (event.ok)
|
|
7662
|
+
output = event.output;
|
|
7663
|
+
else
|
|
7664
|
+
error = event.error?.message ?? "Workflow tool failed";
|
|
7665
|
+
}
|
|
7666
|
+
if (!received)
|
|
7667
|
+
throw new Error("Workflow tool outcome is unknown; action not retried");
|
|
7668
|
+
if (error)
|
|
7669
|
+
throw new Error(error);
|
|
7670
|
+
return output;
|
|
7671
|
+
}
|
|
7672
|
+
};
|
|
7673
|
+
}
|
|
7674
|
+
var init_workflow_tool_runner = __esm({
|
|
7675
|
+
"../core/dist/workflow-tool-runner.js"() {
|
|
7676
|
+
}
|
|
7677
|
+
});
|
|
7678
|
+
function approvalFingerprint(value2) {
|
|
7679
|
+
function canonical2(v) {
|
|
7680
|
+
if (Array.isArray(v))
|
|
7681
|
+
return v.map(canonical2);
|
|
7682
|
+
if (v && typeof v === "object")
|
|
7683
|
+
return Object.fromEntries(Object.entries(v).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => [key, canonical2(item)]));
|
|
7684
|
+
return v;
|
|
7685
|
+
}
|
|
7686
|
+
return createHash("sha256").update(JSON.stringify(canonical2(value2))).digest("hex");
|
|
7687
|
+
}
|
|
7688
|
+
function alive(pid) {
|
|
7689
|
+
try {
|
|
7690
|
+
process.kill(pid, 0);
|
|
7691
|
+
return true;
|
|
7692
|
+
} catch (error) {
|
|
7693
|
+
return error.code !== "ESRCH";
|
|
7694
|
+
}
|
|
7695
|
+
}
|
|
7696
|
+
function runKey(scope2) {
|
|
7697
|
+
const hash = approvalFingerprint([scope2.workflowId, scope2.runId]);
|
|
7698
|
+
return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-4${hash.slice(13, 16)}-8${hash.slice(17, 20)}-${hash.slice(20, 32)}`;
|
|
7699
|
+
}
|
|
7700
|
+
var idSchema, choiceSchema, requestSchema, decisionSchema, markerSchema, WorkflowApprovals;
|
|
7701
|
+
var init_workflow_approvals = __esm({
|
|
7702
|
+
"../core/dist/permissions/workflow-approvals.js"() {
|
|
7703
|
+
idSchema = z.string().uuid();
|
|
7704
|
+
choiceSchema = z.enum(["allow_once", "allow_always", "deny"]);
|
|
7705
|
+
requestSchema = z.object({
|
|
7706
|
+
id: idSchema,
|
|
7707
|
+
workflowId: z.string().min(1),
|
|
7708
|
+
workflowName: z.string().min(1),
|
|
7709
|
+
revision: z.string().min(1),
|
|
7710
|
+
runId: z.string().min(1),
|
|
7711
|
+
tool: z.string().min(1),
|
|
7712
|
+
input: z.unknown(),
|
|
7713
|
+
fingerprint: z.string().length(64),
|
|
7714
|
+
createdAt: z.number().positive(),
|
|
7715
|
+
pid: z.number().int().positive()
|
|
7716
|
+
}).strict();
|
|
7717
|
+
decisionSchema = z.object({ choice: choiceSchema, createdAt: z.number().positive() }).strict();
|
|
7718
|
+
markerSchema = z.object({ createdAt: z.number().positive() }).strict();
|
|
7719
|
+
WorkflowApprovals = class {
|
|
7720
|
+
dir;
|
|
7721
|
+
calls = /* @__PURE__ */ new Map();
|
|
7722
|
+
receipts = /* @__PURE__ */ new Map();
|
|
7723
|
+
constructor(dir) {
|
|
7724
|
+
this.dir = dir;
|
|
7725
|
+
}
|
|
7726
|
+
file(kind, id) {
|
|
7727
|
+
return join(this.dir, kind, idSchema.parse(id) + ".json");
|
|
7728
|
+
}
|
|
7729
|
+
async read(kind, id, schema) {
|
|
7730
|
+
try {
|
|
7731
|
+
const raw = await readFile(this.file(kind, id), "utf8");
|
|
7732
|
+
if (Buffer.byteLength(raw) > 1048576)
|
|
7733
|
+
throw new Error("Approval record exceeds size limit");
|
|
7734
|
+
return schema.parse(JSON.parse(raw));
|
|
7735
|
+
} catch (error) {
|
|
7736
|
+
if (error.code === "ENOENT")
|
|
7737
|
+
return null;
|
|
7738
|
+
throw error;
|
|
7739
|
+
}
|
|
7740
|
+
}
|
|
7741
|
+
async publish(kind, id, value2) {
|
|
7742
|
+
const folder = join(this.dir, kind);
|
|
7743
|
+
await mkdir(folder, { recursive: true, mode: 448 });
|
|
7744
|
+
const target = this.file(kind, id);
|
|
7745
|
+
const temporary = join(folder, "." + randomUUID() + ".tmp");
|
|
7746
|
+
const json = JSON.stringify(value2);
|
|
7747
|
+
if (Buffer.byteLength(json) > 1048576)
|
|
7748
|
+
throw new Error("Approval record exceeds size limit");
|
|
7749
|
+
try {
|
|
7750
|
+
await writeFile(temporary, json, { mode: 384, flag: "wx" });
|
|
7751
|
+
await link(temporary, target);
|
|
7752
|
+
} finally {
|
|
7753
|
+
await unlink(temporary).catch(() => {
|
|
7754
|
+
});
|
|
7755
|
+
}
|
|
7756
|
+
}
|
|
7757
|
+
async requests() {
|
|
7758
|
+
let names;
|
|
7759
|
+
try {
|
|
7760
|
+
names = await readdir(join(this.dir, "requests"));
|
|
7761
|
+
} catch (error) {
|
|
7762
|
+
if (error.code === "ENOENT")
|
|
7763
|
+
return [];
|
|
7764
|
+
throw error;
|
|
7765
|
+
}
|
|
7766
|
+
const result = [];
|
|
7767
|
+
for (const name of names.filter((name2) => name2.endsWith(".json"))) {
|
|
7768
|
+
const request = await this.read("requests", name.slice(0, -5), requestSchema);
|
|
7769
|
+
if (request)
|
|
7770
|
+
result.push(request);
|
|
7771
|
+
}
|
|
7772
|
+
return result;
|
|
7773
|
+
}
|
|
7774
|
+
async list() {
|
|
7775
|
+
return Promise.all((await this.requests()).map(async (request) => {
|
|
7776
|
+
const decision = await this.read("decisions", request.id, decisionSchema);
|
|
7777
|
+
const revoked = await this.read("revoked", request.id, markerSchema);
|
|
7778
|
+
const cancelled = await this.read("cancelled", request.id, markerSchema) || await this.isCancelled(request);
|
|
7779
|
+
const status = revoked ? "revoked" : cancelled ? "cancelled" : decision ? decision.choice === "deny" ? "denied" : "allowed" : alive(request.pid) ? "pending" : "interrupted";
|
|
7780
|
+
const { pid: _pid, fingerprint: _fingerprint, ...item } = request;
|
|
7781
|
+
return {
|
|
7782
|
+
...item,
|
|
7783
|
+
input: request.input,
|
|
7784
|
+
status,
|
|
7785
|
+
...decision ? { choice: decision.choice } : {}
|
|
7786
|
+
};
|
|
7787
|
+
}));
|
|
7788
|
+
}
|
|
7789
|
+
async decide(id, choice) {
|
|
7790
|
+
choiceSchema.parse(choice);
|
|
7791
|
+
const item = (await this.list()).find((item2) => item2.id === idSchema.parse(id));
|
|
7792
|
+
if (!item || item.status !== "pending")
|
|
7793
|
+
throw new Error("Approval is no longer pending");
|
|
7794
|
+
await this.publish("decisions", id, { choice, createdAt: Date.now() });
|
|
7795
|
+
}
|
|
7796
|
+
async revoke(id) {
|
|
7797
|
+
const decision = await this.read("decisions", id, decisionSchema);
|
|
7798
|
+
if (decision?.choice !== "allow_always")
|
|
7799
|
+
throw new Error("No persistent approval to revoke");
|
|
7800
|
+
await this.publish("revoked", id, { createdAt: Date.now() });
|
|
7801
|
+
}
|
|
7802
|
+
async cancel(id) {
|
|
7803
|
+
const request = await this.read("requests", id, requestSchema);
|
|
7804
|
+
if (!request)
|
|
7805
|
+
throw new Error("Unknown approval");
|
|
7806
|
+
if (!await this.isCancelled(request)) {
|
|
7807
|
+
try {
|
|
7808
|
+
await this.publish("stopped-runs", runKey(request), { createdAt: Date.now() });
|
|
7809
|
+
} catch (error) {
|
|
7810
|
+
if (error.code !== "EEXIST")
|
|
7811
|
+
throw error;
|
|
7812
|
+
}
|
|
7813
|
+
}
|
|
7814
|
+
}
|
|
7815
|
+
async isCancelled(scope2) {
|
|
7816
|
+
return !!await this.read("stopped-runs", runKey(scope2), markerSchema);
|
|
7817
|
+
}
|
|
7818
|
+
async finishRun(runId) {
|
|
7819
|
+
for (const key of this.calls.keys())
|
|
7820
|
+
if (key.startsWith(runId + ":")) {
|
|
7821
|
+
this.calls.delete(key);
|
|
7822
|
+
this.receipts.delete(key);
|
|
7823
|
+
}
|
|
7824
|
+
for (const request of await this.requests()) {
|
|
7825
|
+
if (request.runId !== runId || await this.read("decisions", request.id, decisionSchema) || await this.read("cancelled", request.id, markerSchema))
|
|
7826
|
+
continue;
|
|
7827
|
+
await this.publish("cancelled", request.id, { createdAt: Date.now() });
|
|
7828
|
+
}
|
|
7829
|
+
}
|
|
7830
|
+
async check(scope2, call, signal, valid = async () => true) {
|
|
7831
|
+
const key = scope2.runId + ":" + approvalFingerprint([scope2, call]);
|
|
7832
|
+
let pending = this.calls.get(key);
|
|
7833
|
+
if (!pending) {
|
|
7834
|
+
pending = this.resolve(scope2, call, signal, valid, key);
|
|
7835
|
+
this.calls.set(key, pending);
|
|
7836
|
+
}
|
|
7837
|
+
const decision = await pending;
|
|
7838
|
+
const receipt = this.receipts.get(key);
|
|
7839
|
+
if (signal.aborted || await this.isCancelled(scope2) || !await valid() || receipt && await this.read("revoked", receipt, markerSchema)) {
|
|
7840
|
+
return { mode: "deny", reason: "Workflow approval revoked, changed or cancelled" };
|
|
7841
|
+
}
|
|
7842
|
+
return decision;
|
|
7843
|
+
}
|
|
7844
|
+
async resolve(scope2, call, signal, valid, key) {
|
|
7845
|
+
const deny = { mode: "deny", reason: "Workflow action denied or cancelled" };
|
|
7846
|
+
if (signal.aborted || await this.isCancelled(scope2) || !await valid())
|
|
7847
|
+
return deny;
|
|
7848
|
+
const fingerprint2 = approvalFingerprint({ name: call.name, input: call.input });
|
|
7849
|
+
for (const old of await this.requests()) {
|
|
7850
|
+
if (old.workflowId !== scope2.workflowId || old.revision !== scope2.revision || old.fingerprint !== fingerprint2)
|
|
7851
|
+
continue;
|
|
7852
|
+
const decision = await this.read("decisions", old.id, decisionSchema);
|
|
7853
|
+
if (decision?.choice === "deny" && old.runId === scope2.runId)
|
|
7854
|
+
return deny;
|
|
7855
|
+
if (decision?.choice === "allow_always" && await this.read("consumed", old.id, markerSchema) && !await this.read("revoked", old.id, markerSchema) && !await this.read("cancelled", old.id, markerSchema)) {
|
|
7856
|
+
this.receipts.set(key, old.id);
|
|
7857
|
+
return { mode: "allow" };
|
|
7858
|
+
}
|
|
7859
|
+
}
|
|
7860
|
+
const request = requestSchema.parse({
|
|
7861
|
+
...scope2,
|
|
7862
|
+
id: randomUUID(),
|
|
7863
|
+
tool: call.name,
|
|
7864
|
+
input: call.input,
|
|
7865
|
+
fingerprint: fingerprint2,
|
|
7866
|
+
createdAt: Date.now(),
|
|
7867
|
+
pid: process.pid
|
|
7868
|
+
});
|
|
7869
|
+
await this.publish("requests", request.id, request);
|
|
7870
|
+
this.receipts.set(key, request.id);
|
|
7871
|
+
try {
|
|
7872
|
+
while (!signal.aborted && !await this.isCancelled(scope2) && await valid()) {
|
|
7873
|
+
const decision = await this.read("decisions", request.id, decisionSchema);
|
|
7874
|
+
if (decision) {
|
|
7875
|
+
if (signal.aborted || await this.isCancelled(scope2) || !await valid())
|
|
7876
|
+
break;
|
|
7877
|
+
await this.publish("consumed", request.id, { createdAt: Date.now() });
|
|
7878
|
+
return decision.choice === "deny" ? deny : { mode: "allow" };
|
|
7879
|
+
}
|
|
7880
|
+
await setTimeout$1(100, void 0, { signal });
|
|
7881
|
+
}
|
|
7882
|
+
} catch (error) {
|
|
7883
|
+
if (!signal.aborted)
|
|
7884
|
+
throw error;
|
|
7885
|
+
}
|
|
7886
|
+
await this.publish("cancelled", request.id, { createdAt: Date.now() });
|
|
7887
|
+
return deny;
|
|
7888
|
+
}
|
|
7889
|
+
};
|
|
7890
|
+
}
|
|
7891
|
+
});
|
|
7892
|
+
async function claimWorkflowLease(dir, workflowId, signal) {
|
|
7893
|
+
const folder = join(dir, createHash("sha256").update(workflowId).digest("hex"));
|
|
7894
|
+
await mkdir(folder, { recursive: true, mode: 448 });
|
|
7895
|
+
const own = { id: randomUUID(), pid: process.pid, ticket: 0 };
|
|
7896
|
+
const file = join(folder, own.id + ".json");
|
|
7897
|
+
const release = async () => {
|
|
7898
|
+
await unlink(file).catch((error) => {
|
|
7899
|
+
if (error.code !== "ENOENT")
|
|
7900
|
+
throw error;
|
|
7901
|
+
});
|
|
7902
|
+
};
|
|
7903
|
+
async function participants() {
|
|
7904
|
+
const all = [];
|
|
7905
|
+
for (const name of await readdir(folder)) {
|
|
7906
|
+
if (!name.endsWith(".json"))
|
|
7907
|
+
continue;
|
|
7908
|
+
z.string().uuid().parse(name.slice(0, -5));
|
|
7909
|
+
try {
|
|
7910
|
+
const raw = await readFile(join(folder, name), "utf8");
|
|
7911
|
+
if (raw.length > 2048)
|
|
7912
|
+
throw new Error("Invalid workflow lease");
|
|
7913
|
+
const ticket = ticketSchema.parse(JSON.parse(raw));
|
|
7914
|
+
if (ticket.id + ".json" !== name)
|
|
7915
|
+
throw new Error("Workflow lease identity mismatch");
|
|
7916
|
+
try {
|
|
7917
|
+
process.kill(ticket.pid, 0);
|
|
7918
|
+
} catch (error) {
|
|
7919
|
+
if (error.code === "ESRCH")
|
|
7920
|
+
continue;
|
|
7921
|
+
}
|
|
7922
|
+
all.push(ticket);
|
|
7923
|
+
} catch (error) {
|
|
7924
|
+
if (error.code !== "ENOENT")
|
|
7925
|
+
throw error;
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
return all;
|
|
7929
|
+
}
|
|
7930
|
+
try {
|
|
7931
|
+
signal.throwIfAborted();
|
|
7932
|
+
await writeFileAtomic(file, JSON.stringify(own), { mode: 384 });
|
|
7933
|
+
own.ticket = Math.max(0, ...(await participants()).map((item) => item.ticket)) + 1;
|
|
7934
|
+
ticketSchema.parse(own);
|
|
7935
|
+
await writeFileAtomic(file, JSON.stringify(own), { mode: 384 });
|
|
7936
|
+
const deadline = Date.now() + 3e3;
|
|
7937
|
+
for (; ; ) {
|
|
7938
|
+
signal.throwIfAborted();
|
|
7939
|
+
const others = (await participants()).filter((item) => item.id !== own.id);
|
|
7940
|
+
if (others.some((item) => item.ticket === 0)) {
|
|
7941
|
+
if (Date.now() >= deadline)
|
|
7942
|
+
throw new Error("Workflow execution skipped: another runner is acquiring control");
|
|
7943
|
+
await setTimeout$1(10, void 0, { signal });
|
|
7944
|
+
continue;
|
|
7945
|
+
}
|
|
7946
|
+
if (others.some((item) => item.ticket < own.ticket || item.ticket === own.ticket && item.id < own.id)) {
|
|
7947
|
+
throw new Error("Workflow execution skipped: another execution is running or awaiting approval");
|
|
7948
|
+
}
|
|
7949
|
+
return release;
|
|
7950
|
+
}
|
|
7951
|
+
} catch (error) {
|
|
7952
|
+
await release();
|
|
7953
|
+
throw error;
|
|
7954
|
+
}
|
|
7955
|
+
}
|
|
7956
|
+
var ticketSchema;
|
|
7957
|
+
var init_workflow_lease = __esm({
|
|
7958
|
+
"../core/dist/permissions/workflow-lease.js"() {
|
|
7959
|
+
ticketSchema = z.object({
|
|
7960
|
+
id: z.string().uuid(),
|
|
7961
|
+
pid: z.number().int().positive(),
|
|
7962
|
+
ticket: z.number().int().nonnegative().safe()
|
|
7963
|
+
}).strict();
|
|
7964
|
+
}
|
|
7965
|
+
});
|
|
7598
7966
|
|
|
7599
7967
|
// ../core/dist/setup-agent.js
|
|
7600
7968
|
function resolvePermissions(p) {
|
|
@@ -7869,7 +8237,7 @@ async function discoverSkills(opts = {}) {
|
|
|
7869
8237
|
}
|
|
7870
8238
|
return [...seenNames.values()];
|
|
7871
8239
|
}
|
|
7872
|
-
async function loadDir(dir,
|
|
8240
|
+
async function loadDir(dir, scope2, logger, depth = 0) {
|
|
7873
8241
|
let entries;
|
|
7874
8242
|
try {
|
|
7875
8243
|
entries = await promises.readdir(dir, { withFileTypes: true });
|
|
@@ -7886,7 +8254,7 @@ async function loadDir(dir, scope, logger, depth = 0) {
|
|
|
7886
8254
|
});
|
|
7887
8255
|
continue;
|
|
7888
8256
|
}
|
|
7889
|
-
out.push(...await loadDir(path3.join(dir, entry.name),
|
|
8257
|
+
out.push(...await loadDir(path3.join(dir, entry.name), scope2, logger, depth + 1));
|
|
7890
8258
|
continue;
|
|
7891
8259
|
}
|
|
7892
8260
|
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
@@ -7911,9 +8279,9 @@ async function loadDir(dir, scope, logger, depth = 0) {
|
|
|
7911
8279
|
const fm = parsed.data;
|
|
7912
8280
|
const finalTriggers = fm.triggers && fm.triggers.length > 0 ? fm.triggers : deriveTriggers(fm.name);
|
|
7913
8281
|
out.push({
|
|
7914
|
-
id: asSkillId(`${
|
|
8282
|
+
id: asSkillId(`${scope2}/${fm.name}`),
|
|
7915
8283
|
path: full,
|
|
7916
|
-
scope,
|
|
8284
|
+
scope: scope2,
|
|
7917
8285
|
frontmatter: { ...fm, triggers: finalTriggers },
|
|
7918
8286
|
body: body.trimEnd()
|
|
7919
8287
|
});
|
|
@@ -7979,11 +8347,11 @@ var init_synthesize_draft = __esm({
|
|
|
7979
8347
|
The body is the instructions for future invocations. Keep it under 30 lines. Numbered steps preferred.`;
|
|
7980
8348
|
}
|
|
7981
8349
|
});
|
|
7982
|
-
async function synthesizeSkill(session, intent,
|
|
8350
|
+
async function synthesizeSkill(session, intent, scope2, opts = {}, turnId) {
|
|
7983
8351
|
const provider = session.providers.getActive();
|
|
7984
8352
|
const model = opts.model ?? session.lastResolvedModel ?? provider.models[0]?.id ?? "default";
|
|
7985
8353
|
const draft = await draftSkill(provider, model, intent, session.signal);
|
|
7986
|
-
const baseDir =
|
|
8354
|
+
const baseDir = scope2 === "project" ? opts.projectDir ?? defaultProjectSkillsDir(session.cwd) : opts.userDir ?? defaultUserSkillsDir();
|
|
7987
8355
|
await promises.mkdir(baseDir, { recursive: true });
|
|
7988
8356
|
const parsed = skillFrontmatterSchema.safeParse(draft.frontmatter);
|
|
7989
8357
|
if (!parsed.success) {
|
|
@@ -7994,9 +8362,9 @@ async function synthesizeSkill(session, intent, scope, opts = {}, turnId) {
|
|
|
7994
8362
|
const finalPath = await writeUniqueSkill(baseDir, slugify(frontmatter.name), draft.raw);
|
|
7995
8363
|
const basename8 = path3.basename(finalPath, ".md");
|
|
7996
8364
|
const skill = {
|
|
7997
|
-
id: asSkillId(`${
|
|
8365
|
+
id: asSkillId(`${scope2}/${basename8}`),
|
|
7998
8366
|
path: finalPath,
|
|
7999
|
-
scope,
|
|
8367
|
+
scope: scope2,
|
|
8000
8368
|
frontmatter,
|
|
8001
8369
|
body: draft.body.trimEnd()
|
|
8002
8370
|
};
|
|
@@ -8010,7 +8378,7 @@ async function synthesizeSkill(session, intent, scope, opts = {}, turnId) {
|
|
|
8010
8378
|
skillId: skill.id,
|
|
8011
8379
|
name: skill.frontmatter.name,
|
|
8012
8380
|
path: finalPath,
|
|
8013
|
-
scope,
|
|
8381
|
+
scope: scope2,
|
|
8014
8382
|
originatingPrompt: intent
|
|
8015
8383
|
});
|
|
8016
8384
|
} catch (err) {
|
|
@@ -8024,13 +8392,13 @@ async function synthesizeSkill(session, intent, scope, opts = {}, turnId) {
|
|
|
8024
8392
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8025
8393
|
sessionId: String(session.id),
|
|
8026
8394
|
originatingPrompt: intent,
|
|
8027
|
-
scope
|
|
8395
|
+
scope: scope2
|
|
8028
8396
|
});
|
|
8029
8397
|
} catch (err) {
|
|
8030
8398
|
process.stderr.write(`moxxy: synthesize_skill audit append failed (${auditPath}): ${err instanceof Error ? err.message : String(err)}
|
|
8031
8399
|
`);
|
|
8032
8400
|
}
|
|
8033
|
-
return { skill, path: finalPath, scope };
|
|
8401
|
+
return { skill, path: finalPath, scope: scope2 };
|
|
8034
8402
|
}
|
|
8035
8403
|
function slugify(name) {
|
|
8036
8404
|
return name.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
@@ -8101,8 +8469,8 @@ function buildSynthesizeSkillPlugin(session, opts = {}) {
|
|
|
8101
8469
|
timeMs: 12e4
|
|
8102
8470
|
}
|
|
8103
8471
|
},
|
|
8104
|
-
handler: async ({ intent, scope }, ctx) => {
|
|
8105
|
-
const result = await synthesizeSkill(session, intent,
|
|
8472
|
+
handler: async ({ intent, scope: scope2 }, ctx) => {
|
|
8473
|
+
const result = await synthesizeSkill(session, intent, scope2, opts, ctx.turnId);
|
|
8106
8474
|
return {
|
|
8107
8475
|
path: result.path,
|
|
8108
8476
|
scope: result.scope,
|
|
@@ -8644,7 +9012,7 @@ var require_jiti = __commonJS({
|
|
|
8644
9012
|
function V2() {
|
|
8645
9013
|
return 10 !== n2.getToken() ? (k2(3, [], [2, 5]), false) : (P2(false), 6 === n2.getToken() ? (I3(":"), T2(), U3() || k2(4, [], [2, 5])) : k2(5, [], [2, 5]), a2.pop(), true);
|
|
8646
9014
|
}
|
|
8647
|
-
function
|
|
9015
|
+
function z68() {
|
|
8648
9016
|
l2(), T2();
|
|
8649
9017
|
let e5 = false;
|
|
8650
9018
|
for (; 2 !== n2.getToken() && 17 !== n2.getToken(); ) {
|
|
@@ -8671,14 +9039,14 @@ var require_jiti = __commonJS({
|
|
|
8671
9039
|
case 3:
|
|
8672
9040
|
return G2();
|
|
8673
9041
|
case 1:
|
|
8674
|
-
return
|
|
9042
|
+
return z68();
|
|
8675
9043
|
case 10:
|
|
8676
9044
|
return P2(true);
|
|
8677
9045
|
default:
|
|
8678
9046
|
return J3();
|
|
8679
9047
|
}
|
|
8680
9048
|
}
|
|
8681
|
-
return r(T2, "scanNext"), r(k2, "handleError"), r(P2, "parseString"), r(J3, "parseLiteral"), r(V2, "parseProperty"), r(
|
|
9049
|
+
return r(T2, "scanNext"), r(k2, "handleError"), r(P2, "parseString"), r(J3, "parseLiteral"), r(V2, "parseProperty"), r(z68, "parseObject"), r(G2, "parseArray"), r(U3, "parseValue"), T2(), 17 === n2.getToken() ? !!i3.allowEmptyContent || (k2(4, [], []), false) : U3() ? (17 !== n2.getToken() && k2(9, [], []), true) : (k2(4, [], []), false);
|
|
8682
9050
|
}
|
|
8683
9051
|
new Array(W3).fill(0).map((e4, t3) => "\n" + " ".repeat(t3)), new Array(W3).fill(0).map((e4, t3) => "\r" + " ".repeat(t3)), new Array(W3).fill(0).map((e4, t3) => "\r\n" + " ".repeat(t3)), new Array(W3).fill(0).map((e4, t3) => "\n" + " ".repeat(t3)), new Array(W3).fill(0).map((e4, t3) => "\r" + " ".repeat(t3)), new Array(W3).fill(0).map((e4, t3) => "\r\n" + " ".repeat(t3)), (function(e4) {
|
|
8684
9052
|
e4.DEFAULT = { allowTrailingComma: false };
|
|
@@ -12584,13 +12952,16 @@ __export(dist_exports, {
|
|
|
12584
12952
|
TranscriberRegistry: () => TranscriberRegistry,
|
|
12585
12953
|
TunnelProviderRegistry: () => TunnelProviderRegistry,
|
|
12586
12954
|
ViewRendererRegistry: () => ViewRendererRegistry,
|
|
12955
|
+
WorkflowApprovals: () => WorkflowApprovals,
|
|
12587
12956
|
appendAuditRecord: () => appendAuditRecord,
|
|
12957
|
+
approvalFingerprint: () => approvalFingerprint,
|
|
12588
12958
|
attachAuditSink: () => attachAuditSink,
|
|
12589
12959
|
auditDir: () => auditDir,
|
|
12590
12960
|
auditFileFor: () => auditFileFor,
|
|
12591
12961
|
autoAllowResolver: () => autoAllowResolver,
|
|
12592
12962
|
buildSynthesizeSkillPlugin: () => buildSynthesizeSkillPlugin,
|
|
12593
12963
|
chainRecord: () => chainRecord,
|
|
12964
|
+
claimWorkflowLease: () => claimWorkflowLease,
|
|
12594
12965
|
clearRetainedChildren: () => clearRetainedChildren,
|
|
12595
12966
|
clearUsageStats: () => clearUsageStats,
|
|
12596
12967
|
collectTurn: () => collectTurn,
|
|
@@ -12601,6 +12972,7 @@ __export(dist_exports, {
|
|
|
12601
12972
|
createLogger: () => createLogger,
|
|
12602
12973
|
createPluginLoader: () => createPluginLoader,
|
|
12603
12974
|
createSubagentSpawner: () => createSubagentSpawner,
|
|
12975
|
+
createWorkflowToolRunner: () => createWorkflowToolRunner,
|
|
12604
12976
|
defaultProjectSkillsDir: () => defaultProjectSkillsDir,
|
|
12605
12977
|
defaultSessionsDir: () => defaultSessionsDir,
|
|
12606
12978
|
defaultUserSkillsDir: () => defaultUserSkillsDir,
|
|
@@ -12650,11 +13022,16 @@ __export(dist_exports, {
|
|
|
12650
13022
|
usageStatsPath: () => usageStatsPath,
|
|
12651
13023
|
validateDoc: () => validateDoc,
|
|
12652
13024
|
verifyAuditDay: () => verifyAuditDay,
|
|
12653
|
-
verifyChain: () => verifyChain
|
|
13025
|
+
verifyChain: () => verifyChain,
|
|
13026
|
+
withPermissionScope: () => withPermissionScope
|
|
12654
13027
|
});
|
|
12655
13028
|
var init_dist2 = __esm({
|
|
12656
13029
|
"../core/dist/index.js"() {
|
|
12657
13030
|
init_session();
|
|
13031
|
+
init_workflow_tool_runner();
|
|
13032
|
+
init_workflow_approvals();
|
|
13033
|
+
init_scope();
|
|
13034
|
+
init_workflow_lease();
|
|
12658
13035
|
init_run_turn();
|
|
12659
13036
|
init_setup_agent();
|
|
12660
13037
|
init_subagents();
|
|
@@ -13239,7 +13616,7 @@ function withoutPath(obj, segments) {
|
|
|
13239
13616
|
return Object.keys(child).length === 0 ? [] : [[key, child]];
|
|
13240
13617
|
}));
|
|
13241
13618
|
}
|
|
13242
|
-
function stripLockedKeys(config, locked,
|
|
13619
|
+
function stripLockedKeys(config, locked, scope2) {
|
|
13243
13620
|
if (locked.length === 0)
|
|
13244
13621
|
return { config, overrides: [] };
|
|
13245
13622
|
let clone = structuredClone(config);
|
|
@@ -13250,7 +13627,7 @@ function stripLockedKeys(config, locked, scope) {
|
|
|
13250
13627
|
continue;
|
|
13251
13628
|
if (!hasPath(clone, segments))
|
|
13252
13629
|
continue;
|
|
13253
|
-
overrides.push({ key, scope });
|
|
13630
|
+
overrides.push({ key, scope: scope2 });
|
|
13254
13631
|
clone = withoutPath(clone, segments);
|
|
13255
13632
|
}
|
|
13256
13633
|
return { config: clone, overrides };
|
|
@@ -20697,8 +21074,8 @@ var init_loader3 = __esm({
|
|
|
20697
21074
|
cachedJiti = /* @__PURE__ */ new Map();
|
|
20698
21075
|
}
|
|
20699
21076
|
});
|
|
20700
|
-
async function findScopePath(
|
|
20701
|
-
if (
|
|
21077
|
+
async function findScopePath(scope2, cwd2) {
|
|
21078
|
+
if (scope2 === "user") {
|
|
20702
21079
|
const yaml = USER_YAML();
|
|
20703
21080
|
try {
|
|
20704
21081
|
await promises.access(yaml);
|
|
@@ -20709,8 +21086,8 @@ async function findScopePath(scope, cwd2) {
|
|
|
20709
21086
|
}
|
|
20710
21087
|
return findUpward(cwd2, PROJECT_YAML_NAMES);
|
|
20711
21088
|
}
|
|
20712
|
-
function scopeDefaultPath(
|
|
20713
|
-
return
|
|
21089
|
+
function scopeDefaultPath(scope2, cwd2) {
|
|
21090
|
+
return scope2 === "user" ? USER_YAML() : path3.join(cwd2, "moxxy.config.yaml");
|
|
20714
21091
|
}
|
|
20715
21092
|
function parseDotPath(p) {
|
|
20716
21093
|
return p.split(".").map((seg) => /^\d+$/.test(seg) ? Number(seg) : seg);
|
|
@@ -20748,8 +21125,8 @@ var init_config_writer = __esm({
|
|
|
20748
21125
|
configWriteMutex = createMutex();
|
|
20749
21126
|
}
|
|
20750
21127
|
});
|
|
20751
|
-
async function findScopePath2(
|
|
20752
|
-
if (
|
|
21128
|
+
async function findScopePath2(scope2, cwd2) {
|
|
21129
|
+
if (scope2 === "user") {
|
|
20753
21130
|
const yaml = USER_YAML2();
|
|
20754
21131
|
try {
|
|
20755
21132
|
await promises.access(yaml);
|
|
@@ -20760,8 +21137,8 @@ async function findScopePath2(scope, cwd2) {
|
|
|
20760
21137
|
}
|
|
20761
21138
|
return findUpward(cwd2, PROJECT_YAML_NAMES2);
|
|
20762
21139
|
}
|
|
20763
|
-
function scopeDefaultPath2(
|
|
20764
|
-
return
|
|
21140
|
+
function scopeDefaultPath2(scope2, cwd2) {
|
|
21141
|
+
return scope2 === "user" ? USER_YAML2() : path3.join(cwd2, "moxxy.config.yaml");
|
|
20765
21142
|
}
|
|
20766
21143
|
function isOutsideCwd(target, cwd2) {
|
|
20767
21144
|
const rel = path3.relative(path3.resolve(cwd2), path3.resolve(target));
|
|
@@ -20805,9 +21182,9 @@ function buildConfigPlugin(opts = { cwd: process.cwd() }) {
|
|
|
20805
21182
|
timeMs: 1e4
|
|
20806
21183
|
}
|
|
20807
21184
|
},
|
|
20808
|
-
handler: async ({ scope }) => {
|
|
20809
|
-
const found = await findScopePath2(
|
|
20810
|
-
return { scope, path: found, defaultPath: scopeDefaultPath2(
|
|
21185
|
+
handler: async ({ scope: scope2 }) => {
|
|
21186
|
+
const found = await findScopePath2(scope2, cwd2);
|
|
21187
|
+
return { scope: scope2, path: found, defaultPath: scopeDefaultPath2(scope2, cwd2) };
|
|
20811
21188
|
}
|
|
20812
21189
|
}),
|
|
20813
21190
|
defineTool({
|
|
@@ -20821,12 +21198,12 @@ function buildConfigPlugin(opts = { cwd: process.cwd() }) {
|
|
|
20821
21198
|
timeMs: 1e4
|
|
20822
21199
|
}
|
|
20823
21200
|
},
|
|
20824
|
-
handler: async ({ scope }) => {
|
|
20825
|
-
const found = await findScopePath2(
|
|
21201
|
+
handler: async ({ scope: scope2 }) => {
|
|
21202
|
+
const found = await findScopePath2(scope2, cwd2);
|
|
20826
21203
|
if (!found)
|
|
20827
|
-
return { scope, path: null, text: "" };
|
|
21204
|
+
return { scope: scope2, path: null, text: "" };
|
|
20828
21205
|
const text2 = await promises.readFile(found, "utf8");
|
|
20829
|
-
return { scope, path: found, text: text2 };
|
|
21206
|
+
return { scope: scope2, path: found, text: text2 };
|
|
20830
21207
|
}
|
|
20831
21208
|
}),
|
|
20832
21209
|
defineTool({
|
|
@@ -20844,8 +21221,8 @@ function buildConfigPlugin(opts = { cwd: process.cwd() }) {
|
|
|
20844
21221
|
timeMs: 1e4
|
|
20845
21222
|
}
|
|
20846
21223
|
},
|
|
20847
|
-
handler: async ({ scope, path: dotPath }) => {
|
|
20848
|
-
const found = await findScopePath2(
|
|
21224
|
+
handler: async ({ scope: scope2, path: dotPath }) => {
|
|
21225
|
+
const found = await findScopePath2(scope2, cwd2);
|
|
20849
21226
|
if (!found)
|
|
20850
21227
|
return null;
|
|
20851
21228
|
const yamlMod = await Promise.resolve().then(() => __toESM(require_dist()));
|
|
@@ -20881,9 +21258,9 @@ function buildConfigPlugin(opts = { cwd: process.cwd() }) {
|
|
|
20881
21258
|
timeMs: 3e4
|
|
20882
21259
|
}
|
|
20883
21260
|
},
|
|
20884
|
-
handler: async ({ scope, path: dotPath, value: value2 }) => {
|
|
21261
|
+
handler: async ({ scope: scope2, path: dotPath, value: value2 }) => {
|
|
20885
21262
|
const written = await setConfigValue({
|
|
20886
|
-
scope,
|
|
21263
|
+
scope: scope2,
|
|
20887
21264
|
cwd: cwd2,
|
|
20888
21265
|
path: dotPath,
|
|
20889
21266
|
value: parseValue(value2)
|
|
@@ -20901,7 +21278,7 @@ function buildConfigPlugin(opts = { cwd: process.cwd() }) {
|
|
|
20901
21278
|
}
|
|
20902
21279
|
return {
|
|
20903
21280
|
path: written.path,
|
|
20904
|
-
outsideCwd:
|
|
21281
|
+
outsideCwd: scope2 === "project" && isOutsideCwd(written.path, cwd2),
|
|
20905
21282
|
runtime
|
|
20906
21283
|
};
|
|
20907
21284
|
}
|
|
@@ -20946,18 +21323,18 @@ function buildConfigPlugin(opts = { cwd: process.cwd() }) {
|
|
|
20946
21323
|
timeMs: 3e4
|
|
20947
21324
|
}
|
|
20948
21325
|
},
|
|
20949
|
-
handler: async ({ scope }) => writeMutex2.run(async () => {
|
|
20950
|
-
const existing = await findScopePath2(
|
|
21326
|
+
handler: async ({ scope: scope2 }) => writeMutex2.run(async () => {
|
|
21327
|
+
const existing = await findScopePath2(scope2, cwd2);
|
|
20951
21328
|
if (existing) {
|
|
20952
21329
|
return {
|
|
20953
21330
|
path: existing,
|
|
20954
21331
|
created: false,
|
|
20955
|
-
outsideCwd:
|
|
21332
|
+
outsideCwd: scope2 === "project" && isOutsideCwd(existing, cwd2)
|
|
20956
21333
|
};
|
|
20957
21334
|
}
|
|
20958
|
-
const target = scopeDefaultPath2(
|
|
21335
|
+
const target = scopeDefaultPath2(scope2, cwd2);
|
|
20959
21336
|
await promises.mkdir(path3.dirname(target), { recursive: true });
|
|
20960
|
-
const template = `# moxxy config (${
|
|
21337
|
+
const template = `# moxxy config (${scope2} scope)
|
|
20961
21338
|
# Documentation: https://docs.moxxy.ai
|
|
20962
21339
|
plugins:
|
|
20963
21340
|
provider:
|
|
@@ -20972,7 +21349,7 @@ plugins:
|
|
|
20972
21349
|
return {
|
|
20973
21350
|
path: target,
|
|
20974
21351
|
created: true,
|
|
20975
|
-
outsideCwd:
|
|
21352
|
+
outsideCwd: scope2 === "project" && isOutsideCwd(target, cwd2)
|
|
20976
21353
|
};
|
|
20977
21354
|
})
|
|
20978
21355
|
}),
|
|
@@ -24389,7 +24766,7 @@ async function writeInbox(entry, result, opts = {}) {
|
|
|
24389
24766
|
`firedAt: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
24390
24767
|
entry.cron ? `cron: "${entry.cron}"` : `runAt: ${entry.runAt}`,
|
|
24391
24768
|
entry.channel ? `channel: ${entry.channel}` : null,
|
|
24392
|
-
`outcome: ${result.error ? "error" : "ok"}`,
|
|
24769
|
+
`outcome: ${result.cancelled ? "cancelled" : result.error ? "error" : "ok"}`,
|
|
24393
24770
|
`---`,
|
|
24394
24771
|
""
|
|
24395
24772
|
].filter((line) => line !== null).join("\n");
|
|
@@ -24400,10 +24777,34 @@ ${result.text}` : result.text;
|
|
|
24400
24777
|
return file;
|
|
24401
24778
|
}
|
|
24402
24779
|
async function runSchedule(entry, runner, store, inboxOpts = {}) {
|
|
24780
|
+
if (entry.source === "workflow")
|
|
24781
|
+
await store.update(entry.id, { lastStartedAt: Date.now() });
|
|
24782
|
+
const controller = new AbortController();
|
|
24783
|
+
let checking = false;
|
|
24784
|
+
const checkSchedule = async () => {
|
|
24785
|
+
store.invalidate();
|
|
24786
|
+
const current = await store.get(entry.id);
|
|
24787
|
+
if (!current?.enabled)
|
|
24788
|
+
controller.abort("Workflow schedule disabled or deleted");
|
|
24789
|
+
};
|
|
24790
|
+
const monitor = entry.source === "workflow" ? setInterval(() => {
|
|
24791
|
+
if (checking)
|
|
24792
|
+
return;
|
|
24793
|
+
checking = true;
|
|
24794
|
+
void checkSchedule().catch((error) => controller.abort(error)).finally(() => {
|
|
24795
|
+
checking = false;
|
|
24796
|
+
});
|
|
24797
|
+
}, 200) : void 0;
|
|
24798
|
+
monitor?.unref();
|
|
24403
24799
|
let result;
|
|
24404
24800
|
try {
|
|
24801
|
+
if (entry.source === "workflow") {
|
|
24802
|
+
await checkSchedule();
|
|
24803
|
+
controller.signal.throwIfAborted();
|
|
24804
|
+
}
|
|
24405
24805
|
result = await runner.runPrompt({
|
|
24406
24806
|
prompt: entry.prompt,
|
|
24807
|
+
...entry.source === "workflow" ? { signal: controller.signal } : {},
|
|
24407
24808
|
...entry.model ? { model: entry.model } : {},
|
|
24408
24809
|
scheduleName: entry.name,
|
|
24409
24810
|
// A workflow-mirror row (source='workflow') reads as "Workflow ran";
|
|
@@ -24411,10 +24812,12 @@ async function runSchedule(entry, runner, store, inboxOpts = {}) {
|
|
|
24411
24812
|
origin: entry.source === "workflow" && entry.workflowName ? { kind: "workflow", name: entry.workflowName } : { kind: "schedule", name: entry.name }
|
|
24412
24813
|
});
|
|
24413
24814
|
} catch (err) {
|
|
24414
|
-
result = {
|
|
24815
|
+
result = controller.signal.aborted ? { text: "", cancelled: true } : {
|
|
24415
24816
|
text: "",
|
|
24416
24817
|
error: err instanceof Error ? err.message : String(err)
|
|
24417
24818
|
};
|
|
24819
|
+
} finally {
|
|
24820
|
+
clearInterval(monitor);
|
|
24418
24821
|
}
|
|
24419
24822
|
let inboxPath;
|
|
24420
24823
|
try {
|
|
@@ -24425,13 +24828,14 @@ async function runSchedule(entry, runner, store, inboxOpts = {}) {
|
|
|
24425
24828
|
const isOneShot = !!entry.runAt && !entry.cron;
|
|
24426
24829
|
const patch = {
|
|
24427
24830
|
lastRunAt: now,
|
|
24428
|
-
lastResult: result.error ? "error" : "ok",
|
|
24831
|
+
lastResult: result.cancelled ? "cancelled" : result.error ? "error" : "ok",
|
|
24429
24832
|
...result.error ? { lastError: result.error.slice(0, 500) } : { lastError: void 0 },
|
|
24430
24833
|
...isOneShot ? { enabled: false } : {}
|
|
24431
24834
|
};
|
|
24432
24835
|
await store.update(entry.id, patch);
|
|
24433
24836
|
return {
|
|
24434
|
-
ok: !result.error,
|
|
24837
|
+
ok: !result.cancelled && !result.error,
|
|
24838
|
+
...result.cancelled ? { cancelled: true } : {},
|
|
24435
24839
|
text: result.text,
|
|
24436
24840
|
...result.error ? { error: result.error } : {},
|
|
24437
24841
|
...inboxPath ? { inboxPath } : {}
|
|
@@ -24489,7 +24893,8 @@ var init_skill_sync = __esm({
|
|
|
24489
24893
|
|
|
24490
24894
|
// ../plugin-scheduler/dist/poller.js
|
|
24491
24895
|
function cronBaseline(entry) {
|
|
24492
|
-
|
|
24896
|
+
const baseline = entry.lastRunAt ?? entry.createdAt;
|
|
24897
|
+
return Math.max(baseline, entry.timingChangedAt ?? baseline, entry.lastStartedAt ?? baseline, entry.lastSkippedAt ?? baseline);
|
|
24493
24898
|
}
|
|
24494
24899
|
function nextCronFire(entry) {
|
|
24495
24900
|
if (!entry.cron)
|
|
@@ -24509,6 +24914,8 @@ function isDue(entry, now) {
|
|
|
24509
24914
|
if (!entry.enabled)
|
|
24510
24915
|
return false;
|
|
24511
24916
|
if (entry.runAt && !entry.cron) {
|
|
24917
|
+
if (entry.source === "workflow" && (entry.lastStartedAt ?? 0) >= entry.runAt)
|
|
24918
|
+
return false;
|
|
24512
24919
|
return entry.runAt <= now;
|
|
24513
24920
|
}
|
|
24514
24921
|
if (!entry.cron)
|
|
@@ -24528,6 +24935,7 @@ var init_poller = __esm({
|
|
|
24528
24935
|
NEXT_FIRE_CACHE_MAX = 4096;
|
|
24529
24936
|
SchedulerPoller = class _SchedulerPoller {
|
|
24530
24937
|
opts;
|
|
24938
|
+
activeWorkflows = /* @__PURE__ */ new Map();
|
|
24531
24939
|
timer = null;
|
|
24532
24940
|
running = false;
|
|
24533
24941
|
tickPromise = Promise.resolve();
|
|
@@ -24564,6 +24972,7 @@ var init_poller = __esm({
|
|
|
24564
24972
|
this.timer = null;
|
|
24565
24973
|
}
|
|
24566
24974
|
await this.tickPromise.catch(() => void 0);
|
|
24975
|
+
await Promise.allSettled(this.activeWorkflows.values());
|
|
24567
24976
|
}
|
|
24568
24977
|
/** Fire any due schedules right now, ignoring the timer cadence.
|
|
24569
24978
|
* Returns the number of due schedules that were attempted — counted at the
|
|
@@ -24626,6 +25035,15 @@ var init_poller = __esm({
|
|
|
24626
25035
|
}
|
|
24627
25036
|
if (!due)
|
|
24628
25037
|
continue;
|
|
25038
|
+
if (entry.source === "workflow" && this.activeWorkflows.has(entry.id)) {
|
|
25039
|
+
await this.opts.store.update(entry.id, {
|
|
25040
|
+
lastSkippedAt: now,
|
|
25041
|
+
lastSkipReason: "Previous workflow execution is still running or awaiting approval"
|
|
25042
|
+
});
|
|
25043
|
+
continue;
|
|
25044
|
+
}
|
|
25045
|
+
if (entry.source === "workflow" && this.activeWorkflows.size >= 4)
|
|
25046
|
+
continue;
|
|
24629
25047
|
if (entry.ownerSessionId !== void 0 && this.opts.ownerSessionId !== void 0 && entry.ownerSessionId !== this.opts.ownerSessionId) {
|
|
24630
25048
|
continue;
|
|
24631
25049
|
}
|
|
@@ -24655,26 +25073,35 @@ var init_poller = __esm({
|
|
|
24655
25073
|
attempted += 1;
|
|
24656
25074
|
if (fireKey !== null)
|
|
24657
25075
|
this.rememberFired(fireKey);
|
|
24658
|
-
|
|
24659
|
-
|
|
24660
|
-
|
|
24661
|
-
|
|
24662
|
-
log
|
|
24663
|
-
|
|
24664
|
-
|
|
24665
|
-
|
|
24666
|
-
|
|
24667
|
-
|
|
24668
|
-
|
|
24669
|
-
|
|
24670
|
-
|
|
24671
|
-
|
|
24672
|
-
log
|
|
24673
|
-
|
|
24674
|
-
|
|
24675
|
-
|
|
25076
|
+
const fire = async () => {
|
|
25077
|
+
try {
|
|
25078
|
+
const outcome = await (this.opts.firingLock ? this.opts.firingLock.run(entry.id, () => runSchedule(entry, this.opts.runner, this.opts.store, this.opts.inbox)) : runSchedule(entry, this.opts.runner, this.opts.store, this.opts.inbox));
|
|
25079
|
+
const log = this.opts.logger;
|
|
25080
|
+
if (log?.info) {
|
|
25081
|
+
log.info("scheduler: fired", {
|
|
25082
|
+
schedule: entry.name,
|
|
25083
|
+
ok: outcome.ok,
|
|
25084
|
+
inbox: outcome.inboxPath
|
|
25085
|
+
});
|
|
25086
|
+
}
|
|
25087
|
+
onFired?.(entry, { ok: outcome.ok, text: outcome.text });
|
|
25088
|
+
} catch (err) {
|
|
25089
|
+
const log = this.opts.logger;
|
|
25090
|
+
if (log?.error) {
|
|
25091
|
+
log.error("scheduler: run failed", {
|
|
25092
|
+
schedule: entry.name,
|
|
25093
|
+
err: err instanceof Error ? err.message : String(err)
|
|
25094
|
+
});
|
|
25095
|
+
}
|
|
24676
25096
|
}
|
|
24677
|
-
}
|
|
25097
|
+
};
|
|
25098
|
+
if (entry.source === "workflow") {
|
|
25099
|
+
const running = fire().finally(() => {
|
|
25100
|
+
this.activeWorkflows.delete(entry.id);
|
|
25101
|
+
});
|
|
25102
|
+
this.activeWorkflows.set(entry.id, running);
|
|
25103
|
+
} else
|
|
25104
|
+
await fire();
|
|
24678
25105
|
}
|
|
24679
25106
|
if (this.opts.fireLock) {
|
|
24680
25107
|
await this.opts.fireLock.sweep(now).catch(() => void 0);
|
|
@@ -24708,6 +25135,15 @@ var init_poller = __esm({
|
|
|
24708
25135
|
function defaultSchedulesFile() {
|
|
24709
25136
|
return moxxyPath("schedules.json");
|
|
24710
25137
|
}
|
|
25138
|
+
function repairWorkflowDate(entry, now) {
|
|
25139
|
+
if (entry.source !== "workflow" || entry.createdAt > 0)
|
|
25140
|
+
return entry;
|
|
25141
|
+
return scheduleEntrySchema.parse({
|
|
25142
|
+
...entry,
|
|
25143
|
+
createdAt: entry.lastRunAt && entry.lastRunAt > 0 ? entry.lastRunAt : now,
|
|
25144
|
+
migratedAt: now
|
|
25145
|
+
});
|
|
25146
|
+
}
|
|
24711
25147
|
function isVisibleSchedule(entry) {
|
|
24712
25148
|
return entry.deletedAt === void 0;
|
|
24713
25149
|
}
|
|
@@ -24733,8 +25169,15 @@ var init_store2 = __esm({
|
|
|
24733
25169
|
model: z.string().optional(),
|
|
24734
25170
|
enabled: z.boolean().default(true),
|
|
24735
25171
|
createdAt: z.number().int(),
|
|
25172
|
+
/** New timing definition starts here without overwriting run history. */
|
|
25173
|
+
timingChangedAt: z.number().int().positive().optional(),
|
|
25174
|
+
/** Audit marker for the legacy workflow createdAt=0 repair. */
|
|
25175
|
+
migratedAt: z.number().int().positive().optional(),
|
|
24736
25176
|
lastRunAt: z.number().int().optional(),
|
|
24737
|
-
|
|
25177
|
+
lastStartedAt: z.number().int().positive().optional(),
|
|
25178
|
+
lastSkippedAt: z.number().int().positive().optional(),
|
|
25179
|
+
lastSkipReason: z.string().optional(),
|
|
25180
|
+
lastResult: z.enum(["ok", "error", "cancelled"]).optional(),
|
|
24738
25181
|
lastError: z.string().optional(),
|
|
24739
25182
|
source: scheduleSourceSchema.default("manual"),
|
|
24740
25183
|
/**
|
|
@@ -24784,7 +25227,9 @@ var init_store2 = __esm({
|
|
|
24784
25227
|
// file is quarantined (renamed to `<file>.corrupt-<ts>`) and the store resets
|
|
24785
25228
|
// to empty so the data loss is observable; an unreadable file resets to empty.
|
|
24786
25229
|
store;
|
|
25230
|
+
now;
|
|
24787
25231
|
constructor(opts = {}) {
|
|
25232
|
+
this.now = opts.now ?? Date.now;
|
|
24788
25233
|
const file = opts.file ?? defaultSchedulesFile();
|
|
24789
25234
|
const logger = opts.logger;
|
|
24790
25235
|
this.store = createJsonFileStore({
|
|
@@ -24841,9 +25286,11 @@ var init_store2 = __esm({
|
|
|
24841
25286
|
this.store.invalidate();
|
|
24842
25287
|
}
|
|
24843
25288
|
async list() {
|
|
25289
|
+
await this.migrateWorkflowDates();
|
|
24844
25290
|
return (await this.store.read()).filter(isVisibleSchedule);
|
|
24845
25291
|
}
|
|
24846
25292
|
async get(id) {
|
|
25293
|
+
await this.migrateWorkflowDates();
|
|
24847
25294
|
const entry = await this.store.get(id);
|
|
24848
25295
|
return entry && isVisibleSchedule(entry) ? entry : null;
|
|
24849
25296
|
}
|
|
@@ -25000,19 +25447,43 @@ var init_store2 = __esm({
|
|
|
25000
25447
|
*/
|
|
25001
25448
|
async syncWorkflowSchedule(workflowName2, entry) {
|
|
25002
25449
|
await this.store.mutate((schedules) => {
|
|
25450
|
+
const now = this.now();
|
|
25451
|
+
const current = schedules.find((s) => s.source === "workflow" && s.workflowName === workflowName2);
|
|
25003
25452
|
const existingDeleted = schedules.find((s) => s.source === "workflow" && s.workflowName === workflowName2 && !isVisibleSchedule(s));
|
|
25004
25453
|
const filtered = schedules.filter((s) => !(s.source === "workflow" && s.workflowName === workflowName2));
|
|
25005
25454
|
if (entry) {
|
|
25006
|
-
|
|
25455
|
+
const timingChanged = current && (current.cron !== entry.cron || current.runAt !== entry.runAt || current.timeZone !== entry.timeZone);
|
|
25456
|
+
const merged = scheduleEntrySchema.parse({
|
|
25007
25457
|
...entry,
|
|
25008
|
-
id: entry.id || ulid(),
|
|
25458
|
+
id: current?.id ?? (entry.id || ulid()),
|
|
25459
|
+
createdAt: current?.createdAt ?? (entry.createdAt > 0 ? entry.createdAt : now),
|
|
25460
|
+
enabled: current?.enabled ?? entry.enabled,
|
|
25461
|
+
...current ? {
|
|
25462
|
+
lastRunAt: current.lastRunAt,
|
|
25463
|
+
lastStartedAt: current.lastStartedAt,
|
|
25464
|
+
lastSkippedAt: current.lastSkippedAt,
|
|
25465
|
+
lastSkipReason: current.lastSkipReason,
|
|
25466
|
+
lastResult: current.lastResult,
|
|
25467
|
+
lastError: current.lastError,
|
|
25468
|
+
migratedAt: current.migratedAt,
|
|
25469
|
+
timingChangedAt: timingChanged ? now : current.timingChangedAt
|
|
25470
|
+
} : {},
|
|
25009
25471
|
source: "workflow",
|
|
25010
25472
|
workflowName: workflowName2
|
|
25011
|
-
})
|
|
25473
|
+
});
|
|
25474
|
+
filtered.push(repairWorkflowDate(existingDeleted ?? merged, now));
|
|
25475
|
+
} else if (existingDeleted) {
|
|
25476
|
+
filtered.push(existingDeleted);
|
|
25012
25477
|
}
|
|
25013
25478
|
return filtered;
|
|
25014
25479
|
});
|
|
25015
25480
|
}
|
|
25481
|
+
async migrateWorkflowDates() {
|
|
25482
|
+
const rows = await this.store.read();
|
|
25483
|
+
if (!rows.some((entry) => entry.source === "workflow" && entry.createdAt <= 0))
|
|
25484
|
+
return;
|
|
25485
|
+
await this.store.mutate((entries) => entries.map((entry) => repairWorkflowDate(entry, this.now())));
|
|
25486
|
+
}
|
|
25016
25487
|
};
|
|
25017
25488
|
}
|
|
25018
25489
|
});
|
|
@@ -25041,6 +25512,9 @@ function describeScheduleEntry(entry) {
|
|
|
25041
25512
|
targetSessionId: entry.ownerSessionId ?? null,
|
|
25042
25513
|
createdAt: entry.createdAt,
|
|
25043
25514
|
lastRunAt: entry.lastRunAt ?? null,
|
|
25515
|
+
lastStartedAt: entry.lastStartedAt ?? null,
|
|
25516
|
+
lastSkippedAt: entry.lastSkippedAt ?? null,
|
|
25517
|
+
lastSkipReason: entry.lastSkipReason ?? null,
|
|
25044
25518
|
lastResult: entry.lastResult ?? null,
|
|
25045
25519
|
lastError: entry.lastError ?? null,
|
|
25046
25520
|
nextFireAt,
|
|
@@ -26673,16 +27147,6 @@ function abytes(value2, length, title = "") {
|
|
|
26673
27147
|
}
|
|
26674
27148
|
return value2;
|
|
26675
27149
|
}
|
|
26676
|
-
function ahash(h) {
|
|
26677
|
-
if (typeof h !== "function" || typeof h.create !== "function")
|
|
26678
|
-
throw new TypeError("Hash must wrapped by utils.createHasher");
|
|
26679
|
-
anumber(h.outputLen);
|
|
26680
|
-
anumber(h.blockLen);
|
|
26681
|
-
if (h.outputLen < 1)
|
|
26682
|
-
throw new Error('"outputLen" must be >= 1');
|
|
26683
|
-
if (h.blockLen < 1)
|
|
26684
|
-
throw new Error('"blockLen" must be >= 1');
|
|
26685
|
-
}
|
|
26686
27150
|
function aexists(instance, checkFinished = true) {
|
|
26687
27151
|
if (instance.destroyed)
|
|
26688
27152
|
throw new Error("Hash instance has been destroyed");
|
|
@@ -26704,9 +27168,6 @@ function clean(...arrays) {
|
|
|
26704
27168
|
function createView(arr) {
|
|
26705
27169
|
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
26706
27170
|
}
|
|
26707
|
-
function rotr(word, shift) {
|
|
26708
|
-
return word << 32 - shift | word >>> shift;
|
|
26709
|
-
}
|
|
26710
27171
|
function bytesToHex(bytes) {
|
|
26711
27172
|
abytes(bytes);
|
|
26712
27173
|
if (hasHexBuiltin)
|
|
@@ -26806,13 +27267,7 @@ var init_utils = __esm({
|
|
|
26806
27267
|
});
|
|
26807
27268
|
|
|
26808
27269
|
// ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_md.js
|
|
26809
|
-
|
|
26810
|
-
return a & b ^ ~a & c;
|
|
26811
|
-
}
|
|
26812
|
-
function Maj(a, b, c) {
|
|
26813
|
-
return a & b ^ a & c ^ b & c;
|
|
26814
|
-
}
|
|
26815
|
-
var HashMD, SHA256_IV, SHA512_IV;
|
|
27270
|
+
var HashMD, SHA512_IV;
|
|
26816
27271
|
var init_md = __esm({
|
|
26817
27272
|
"../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_md.js"() {
|
|
26818
27273
|
init_utils();
|
|
@@ -26912,16 +27367,6 @@ var init_md = __esm({
|
|
|
26912
27367
|
return this._cloneInto();
|
|
26913
27368
|
}
|
|
26914
27369
|
};
|
|
26915
|
-
SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
26916
|
-
1779033703,
|
|
26917
|
-
3144134277,
|
|
26918
|
-
1013904242,
|
|
26919
|
-
2773480762,
|
|
26920
|
-
1359893119,
|
|
26921
|
-
2600822924,
|
|
26922
|
-
528734635,
|
|
26923
|
-
1541459225
|
|
26924
|
-
]);
|
|
26925
27370
|
SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
26926
27371
|
1779033703,
|
|
26927
27372
|
4089235720,
|
|
@@ -26984,157 +27429,12 @@ var init_u64 = __esm({
|
|
|
26984
27429
|
});
|
|
26985
27430
|
|
|
26986
27431
|
// ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/sha2.js
|
|
26987
|
-
var
|
|
27432
|
+
var K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA2_64B, _SHA512, sha512;
|
|
26988
27433
|
var init_sha2 = __esm({
|
|
26989
27434
|
"../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/sha2.js"() {
|
|
26990
27435
|
init_md();
|
|
26991
27436
|
init_u64();
|
|
26992
27437
|
init_utils();
|
|
26993
|
-
SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
26994
|
-
1116352408,
|
|
26995
|
-
1899447441,
|
|
26996
|
-
3049323471,
|
|
26997
|
-
3921009573,
|
|
26998
|
-
961987163,
|
|
26999
|
-
1508970993,
|
|
27000
|
-
2453635748,
|
|
27001
|
-
2870763221,
|
|
27002
|
-
3624381080,
|
|
27003
|
-
310598401,
|
|
27004
|
-
607225278,
|
|
27005
|
-
1426881987,
|
|
27006
|
-
1925078388,
|
|
27007
|
-
2162078206,
|
|
27008
|
-
2614888103,
|
|
27009
|
-
3248222580,
|
|
27010
|
-
3835390401,
|
|
27011
|
-
4022224774,
|
|
27012
|
-
264347078,
|
|
27013
|
-
604807628,
|
|
27014
|
-
770255983,
|
|
27015
|
-
1249150122,
|
|
27016
|
-
1555081692,
|
|
27017
|
-
1996064986,
|
|
27018
|
-
2554220882,
|
|
27019
|
-
2821834349,
|
|
27020
|
-
2952996808,
|
|
27021
|
-
3210313671,
|
|
27022
|
-
3336571891,
|
|
27023
|
-
3584528711,
|
|
27024
|
-
113926993,
|
|
27025
|
-
338241895,
|
|
27026
|
-
666307205,
|
|
27027
|
-
773529912,
|
|
27028
|
-
1294757372,
|
|
27029
|
-
1396182291,
|
|
27030
|
-
1695183700,
|
|
27031
|
-
1986661051,
|
|
27032
|
-
2177026350,
|
|
27033
|
-
2456956037,
|
|
27034
|
-
2730485921,
|
|
27035
|
-
2820302411,
|
|
27036
|
-
3259730800,
|
|
27037
|
-
3345764771,
|
|
27038
|
-
3516065817,
|
|
27039
|
-
3600352804,
|
|
27040
|
-
4094571909,
|
|
27041
|
-
275423344,
|
|
27042
|
-
430227734,
|
|
27043
|
-
506948616,
|
|
27044
|
-
659060556,
|
|
27045
|
-
883997877,
|
|
27046
|
-
958139571,
|
|
27047
|
-
1322822218,
|
|
27048
|
-
1537002063,
|
|
27049
|
-
1747873779,
|
|
27050
|
-
1955562222,
|
|
27051
|
-
2024104815,
|
|
27052
|
-
2227730452,
|
|
27053
|
-
2361852424,
|
|
27054
|
-
2428436474,
|
|
27055
|
-
2756734187,
|
|
27056
|
-
3204031479,
|
|
27057
|
-
3329325298
|
|
27058
|
-
]);
|
|
27059
|
-
SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
27060
|
-
SHA2_32B = class extends HashMD {
|
|
27061
|
-
constructor(outputLen) {
|
|
27062
|
-
super(64, outputLen, 8, false);
|
|
27063
|
-
}
|
|
27064
|
-
get() {
|
|
27065
|
-
const { A, B: B2, C: C2, D: D2, E, F, G: G2, H: H3 } = this;
|
|
27066
|
-
return [A, B2, C2, D2, E, F, G2, H3];
|
|
27067
|
-
}
|
|
27068
|
-
// prettier-ignore
|
|
27069
|
-
set(A, B2, C2, D2, E, F, G2, H3) {
|
|
27070
|
-
this.A = A | 0;
|
|
27071
|
-
this.B = B2 | 0;
|
|
27072
|
-
this.C = C2 | 0;
|
|
27073
|
-
this.D = D2 | 0;
|
|
27074
|
-
this.E = E | 0;
|
|
27075
|
-
this.F = F | 0;
|
|
27076
|
-
this.G = G2 | 0;
|
|
27077
|
-
this.H = H3 | 0;
|
|
27078
|
-
}
|
|
27079
|
-
process(view, offset) {
|
|
27080
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
27081
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
27082
|
-
for (let i = 16; i < 64; i++) {
|
|
27083
|
-
const W15 = SHA256_W[i - 15];
|
|
27084
|
-
const W22 = SHA256_W[i - 2];
|
|
27085
|
-
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
27086
|
-
const s1 = rotr(W22, 17) ^ rotr(W22, 19) ^ W22 >>> 10;
|
|
27087
|
-
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
27088
|
-
}
|
|
27089
|
-
let { A, B: B2, C: C2, D: D2, E, F, G: G2, H: H3 } = this;
|
|
27090
|
-
for (let i = 0; i < 64; i++) {
|
|
27091
|
-
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
27092
|
-
const T1 = H3 + sigma1 + Chi(E, F, G2) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
27093
|
-
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
27094
|
-
const T2 = sigma0 + Maj(A, B2, C2) | 0;
|
|
27095
|
-
H3 = G2;
|
|
27096
|
-
G2 = F;
|
|
27097
|
-
F = E;
|
|
27098
|
-
E = D2 + T1 | 0;
|
|
27099
|
-
D2 = C2;
|
|
27100
|
-
C2 = B2;
|
|
27101
|
-
B2 = A;
|
|
27102
|
-
A = T1 + T2 | 0;
|
|
27103
|
-
}
|
|
27104
|
-
A = A + this.A | 0;
|
|
27105
|
-
B2 = B2 + this.B | 0;
|
|
27106
|
-
C2 = C2 + this.C | 0;
|
|
27107
|
-
D2 = D2 + this.D | 0;
|
|
27108
|
-
E = E + this.E | 0;
|
|
27109
|
-
F = F + this.F | 0;
|
|
27110
|
-
G2 = G2 + this.G | 0;
|
|
27111
|
-
H3 = H3 + this.H | 0;
|
|
27112
|
-
this.set(A, B2, C2, D2, E, F, G2, H3);
|
|
27113
|
-
}
|
|
27114
|
-
roundClean() {
|
|
27115
|
-
clean(SHA256_W);
|
|
27116
|
-
}
|
|
27117
|
-
destroy() {
|
|
27118
|
-
this.destroyed = true;
|
|
27119
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
27120
|
-
clean(this.buffer);
|
|
27121
|
-
}
|
|
27122
|
-
};
|
|
27123
|
-
_SHA256 = class extends SHA2_32B {
|
|
27124
|
-
// We cannot use array here since array allows indexing by variable
|
|
27125
|
-
// which means optimizer/compiler cannot use registers.
|
|
27126
|
-
A = SHA256_IV[0] | 0;
|
|
27127
|
-
B = SHA256_IV[1] | 0;
|
|
27128
|
-
C = SHA256_IV[2] | 0;
|
|
27129
|
-
D = SHA256_IV[3] | 0;
|
|
27130
|
-
E = SHA256_IV[4] | 0;
|
|
27131
|
-
F = SHA256_IV[5] | 0;
|
|
27132
|
-
G = SHA256_IV[6] | 0;
|
|
27133
|
-
H = SHA256_IV[7] | 0;
|
|
27134
|
-
constructor() {
|
|
27135
|
-
super(32);
|
|
27136
|
-
}
|
|
27137
|
-
};
|
|
27138
27438
|
K512 = /* @__PURE__ */ (() => split([
|
|
27139
27439
|
"0x428a2f98d728ae22",
|
|
27140
27440
|
"0x7137449123ef65cd",
|
|
@@ -27338,10 +27638,6 @@ var init_sha2 = __esm({
|
|
|
27338
27638
|
super(64);
|
|
27339
27639
|
}
|
|
27340
27640
|
};
|
|
27341
|
-
sha2562 = /* @__PURE__ */ createHasher(
|
|
27342
|
-
() => new _SHA256(),
|
|
27343
|
-
/* @__PURE__ */ oidNist(1)
|
|
27344
|
-
);
|
|
27345
27641
|
sha512 = /* @__PURE__ */ createHasher(
|
|
27346
27642
|
() => new _SHA512(),
|
|
27347
27643
|
/* @__PURE__ */ oidNist(3)
|
|
@@ -28384,7 +28680,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
28384
28680
|
if (outputLen !== expectedLen)
|
|
28385
28681
|
throw new Error(`hash.outputLen must be ${expectedLen}, got ${outputLen}`);
|
|
28386
28682
|
}
|
|
28387
|
-
const
|
|
28683
|
+
const randomBytes9 = opts.randomBytes === void 0 ? randomBytes4 : opts.randomBytes;
|
|
28388
28684
|
const adjustScalarBytes2 = opts.adjustScalarBytes === void 0 ? (bytes) => bytes : opts.adjustScalarBytes;
|
|
28389
28685
|
const domain2 = opts.domain === void 0 ? (data, ctx, phflag) => {
|
|
28390
28686
|
abool(phflag, "phflag");
|
|
@@ -28470,7 +28766,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
28470
28766
|
seed: _size
|
|
28471
28767
|
};
|
|
28472
28768
|
function randomSecretKey(seed) {
|
|
28473
|
-
seed = seed === void 0 ?
|
|
28769
|
+
seed = seed === void 0 ? randomBytes9(lengths.seed) : seed;
|
|
28474
28770
|
return abytes2(seed, lengths.seed, "seed");
|
|
28475
28771
|
}
|
|
28476
28772
|
function isValidSecretKey(key) {
|
|
@@ -28967,6 +29263,466 @@ var init_ed25519 = __esm({
|
|
|
28967
29263
|
}
|
|
28968
29264
|
});
|
|
28969
29265
|
|
|
29266
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/_u64.js
|
|
29267
|
+
function setU64FromNum(view, byteOffset, n, isLE2) {
|
|
29268
|
+
const h = fromNumH(n);
|
|
29269
|
+
const l = fromNumL(n);
|
|
29270
|
+
view.setUint32(byteOffset, isLE2 ? l : h, isLE2);
|
|
29271
|
+
view.setUint32(byteOffset + 4, isLE2 ? h : l, isLE2);
|
|
29272
|
+
}
|
|
29273
|
+
var fromNumH, fromNumL;
|
|
29274
|
+
var init_u642 = __esm({
|
|
29275
|
+
"../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/_u64.js"() {
|
|
29276
|
+
fromNumH = (n) => n / 2 ** 32 | 0;
|
|
29277
|
+
fromNumL = (n) => n >>> 0;
|
|
29278
|
+
}
|
|
29279
|
+
});
|
|
29280
|
+
|
|
29281
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/utils.js
|
|
29282
|
+
function isBytes3(a) {
|
|
29283
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
29284
|
+
}
|
|
29285
|
+
function anumber3(n, title = "") {
|
|
29286
|
+
if (typeof n !== "number")
|
|
29287
|
+
throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
29288
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
29289
|
+
throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
29290
|
+
return n;
|
|
29291
|
+
}
|
|
29292
|
+
function abytes3(value2, length, title = "") {
|
|
29293
|
+
if (isBytes3(value2) && (length === void 0))
|
|
29294
|
+
return value2;
|
|
29295
|
+
const bytes = isBytes3(value2);
|
|
29296
|
+
const ofLen = "";
|
|
29297
|
+
const got = bytes ? `length=${value2.length}` : `type=${typeof value2}`;
|
|
29298
|
+
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
29299
|
+
if (!bytes)
|
|
29300
|
+
throw new TypeError(message);
|
|
29301
|
+
throw new RangeError(message);
|
|
29302
|
+
}
|
|
29303
|
+
function ahash(h) {
|
|
29304
|
+
if (typeof h !== "function" || typeof h.create !== "function")
|
|
29305
|
+
throw new TypeError("expected hash wrapped by utils.createHasher");
|
|
29306
|
+
anumber3(h.outputLen);
|
|
29307
|
+
anumber3(h.blockLen);
|
|
29308
|
+
if (h.outputLen < 1 || h.blockLen < 1)
|
|
29309
|
+
throw new Error("hash blockLen / outputLen must be >= 1");
|
|
29310
|
+
}
|
|
29311
|
+
function aexists2(instance, checkFinished = true) {
|
|
29312
|
+
if (instance.destroyed)
|
|
29313
|
+
throw new Error("hash was destroyed");
|
|
29314
|
+
if (checkFinished && instance.finished)
|
|
29315
|
+
throw new Error("digest() was already called");
|
|
29316
|
+
}
|
|
29317
|
+
function aoutput2(out, instance) {
|
|
29318
|
+
abytes3(out, void 0, "output");
|
|
29319
|
+
const min = instance.outputLen;
|
|
29320
|
+
if (!(out.length >= min)) {
|
|
29321
|
+
throw new RangeError('"output" expected length >= ' + min);
|
|
29322
|
+
}
|
|
29323
|
+
}
|
|
29324
|
+
function clean2(...arrays) {
|
|
29325
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
29326
|
+
arrays[i].fill(0);
|
|
29327
|
+
}
|
|
29328
|
+
}
|
|
29329
|
+
function createView2(arr) {
|
|
29330
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
29331
|
+
}
|
|
29332
|
+
function rotr2(word, shift) {
|
|
29333
|
+
return word << 32 - shift | word >>> shift;
|
|
29334
|
+
}
|
|
29335
|
+
function bytesToHex3(bytes) {
|
|
29336
|
+
abytes3(bytes);
|
|
29337
|
+
if (hasHexBuiltin2)
|
|
29338
|
+
return bytes.toHex();
|
|
29339
|
+
let hex = "";
|
|
29340
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
29341
|
+
hex += hexes2[bytes[i]];
|
|
29342
|
+
}
|
|
29343
|
+
return hex;
|
|
29344
|
+
}
|
|
29345
|
+
function asciiToBase162(ch) {
|
|
29346
|
+
return ch >= 48 && ch <= 57 ? ch - 48 : ch >= 65 && ch <= 70 ? ch - (65 - 10) : ch >= 97 && ch <= 102 ? ch - (97 - 10) : void 0;
|
|
29347
|
+
}
|
|
29348
|
+
function hexToBytes3(hex) {
|
|
29349
|
+
if (typeof hex !== "string")
|
|
29350
|
+
throw new TypeError("hex string expected, got " + typeof hex);
|
|
29351
|
+
if (hasHexBuiltin2) {
|
|
29352
|
+
try {
|
|
29353
|
+
return Uint8Array.fromHex(hex);
|
|
29354
|
+
} catch (error) {
|
|
29355
|
+
if (error instanceof SyntaxError)
|
|
29356
|
+
throw new RangeError(error.message);
|
|
29357
|
+
throw error;
|
|
29358
|
+
}
|
|
29359
|
+
}
|
|
29360
|
+
const hl = hex.length;
|
|
29361
|
+
const al = hl / 2;
|
|
29362
|
+
if (hl % 2)
|
|
29363
|
+
throw new RangeError("hex string expected, got unpadded hex of length " + hl);
|
|
29364
|
+
const array = new Uint8Array(al);
|
|
29365
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
29366
|
+
const n1 = asciiToBase162(hex.charCodeAt(hi));
|
|
29367
|
+
const n2 = asciiToBase162(hex.charCodeAt(hi + 1));
|
|
29368
|
+
if (n1 === void 0 || n2 === void 0) {
|
|
29369
|
+
const char = hex[hi] + hex[hi + 1];
|
|
29370
|
+
throw new RangeError('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
29371
|
+
}
|
|
29372
|
+
array[ai] = n1 * 16 + n2;
|
|
29373
|
+
}
|
|
29374
|
+
return array;
|
|
29375
|
+
}
|
|
29376
|
+
function checkOpts(defaults, opts, title = "opts") {
|
|
29377
|
+
aopts(defaults, "defaults");
|
|
29378
|
+
if (opts !== void 0)
|
|
29379
|
+
aopts(opts, title);
|
|
29380
|
+
const merged = Object.assign(/* @__PURE__ */ Object.create(null), defaults, opts);
|
|
29381
|
+
return merged;
|
|
29382
|
+
}
|
|
29383
|
+
function createHasher3(hashCons, info = {}) {
|
|
29384
|
+
if (typeof hashCons !== "function")
|
|
29385
|
+
throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
|
|
29386
|
+
info = checkOpts({}, info, "info");
|
|
29387
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
29388
|
+
const tmp = hashCons(void 0);
|
|
29389
|
+
hashC.outputLen = tmp.outputLen;
|
|
29390
|
+
hashC.blockLen = tmp.blockLen;
|
|
29391
|
+
hashC.canXOF = tmp.canXOF;
|
|
29392
|
+
hashC.create = (opts) => hashCons(opts);
|
|
29393
|
+
Object.assign(hashC, info);
|
|
29394
|
+
return Object.freeze(hashC);
|
|
29395
|
+
}
|
|
29396
|
+
function randomBytes5(bytesLength = 32) {
|
|
29397
|
+
anumber3(bytesLength, "bytesLength");
|
|
29398
|
+
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
29399
|
+
if (typeof cr?.getRandomValues !== "function")
|
|
29400
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
29401
|
+
if (bytesLength > 65536)
|
|
29402
|
+
throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
29403
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
29404
|
+
}
|
|
29405
|
+
var atitle, aobject, aopts, hasHexBuiltin2, hexes2, oidNist2;
|
|
29406
|
+
var init_utils3 = __esm({
|
|
29407
|
+
"../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/utils.js"() {
|
|
29408
|
+
atitle = (title) => title ? `"${title}" ` : "";
|
|
29409
|
+
aobject = (value2, label3) => {
|
|
29410
|
+
if (value2 === null || typeof value2 !== "object" || Array.isArray(value2))
|
|
29411
|
+
throw new TypeError((label3 === "object" ? "" : `"${label3}" `) + "expected object, got type=" + typeof value2);
|
|
29412
|
+
};
|
|
29413
|
+
aopts = (value2, label3) => {
|
|
29414
|
+
aobject(value2, label3);
|
|
29415
|
+
const proto2 = Object.getPrototypeOf(value2);
|
|
29416
|
+
if (proto2 !== Object.prototype && proto2 !== null)
|
|
29417
|
+
throw new TypeError(`"${label3}" expected plain object`);
|
|
29418
|
+
if (Object.hasOwn(value2, "__proto__"))
|
|
29419
|
+
throw new TypeError(`"${label3}.__proto__" is not allowed`);
|
|
29420
|
+
};
|
|
29421
|
+
hasHexBuiltin2 = /* @__PURE__ */ (() => (
|
|
29422
|
+
// @ts-ignore
|
|
29423
|
+
typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
|
|
29424
|
+
))();
|
|
29425
|
+
hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_2, i) => i.toString(16).padStart(2, "0"));
|
|
29426
|
+
oidNist2 = (suffix) => ({
|
|
29427
|
+
// Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
|
|
29428
|
+
// Larger suffix values would need base-128 OID encoding and a different length byte.
|
|
29429
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
29430
|
+
});
|
|
29431
|
+
}
|
|
29432
|
+
});
|
|
29433
|
+
|
|
29434
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/_md.js
|
|
29435
|
+
function Chi2(a, b, c) {
|
|
29436
|
+
return a & b ^ ~a & c;
|
|
29437
|
+
}
|
|
29438
|
+
function Maj2(a, b, c) {
|
|
29439
|
+
return a & b ^ a & c ^ b & c;
|
|
29440
|
+
}
|
|
29441
|
+
var HashMD2, SHA256_IV2;
|
|
29442
|
+
var init_md2 = __esm({
|
|
29443
|
+
"../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/_md.js"() {
|
|
29444
|
+
init_u642();
|
|
29445
|
+
init_utils3();
|
|
29446
|
+
HashMD2 = class {
|
|
29447
|
+
blockLen;
|
|
29448
|
+
outputLen;
|
|
29449
|
+
canXOF = false;
|
|
29450
|
+
padOffset;
|
|
29451
|
+
isLE;
|
|
29452
|
+
// For partial updates less than block size
|
|
29453
|
+
buffer;
|
|
29454
|
+
view;
|
|
29455
|
+
finished = false;
|
|
29456
|
+
length = 0;
|
|
29457
|
+
pos = 0;
|
|
29458
|
+
destroyed = false;
|
|
29459
|
+
constructor(blockLen, outputLen, padOffset, isLE2) {
|
|
29460
|
+
this.blockLen = blockLen;
|
|
29461
|
+
this.outputLen = outputLen;
|
|
29462
|
+
this.padOffset = padOffset;
|
|
29463
|
+
this.isLE = isLE2;
|
|
29464
|
+
this.buffer = new Uint8Array(blockLen);
|
|
29465
|
+
this.view = createView2(this.buffer);
|
|
29466
|
+
}
|
|
29467
|
+
update(data) {
|
|
29468
|
+
aexists2(this);
|
|
29469
|
+
abytes3(data);
|
|
29470
|
+
const { view, buffer, blockLen } = this;
|
|
29471
|
+
const len = data.length;
|
|
29472
|
+
let processed = false;
|
|
29473
|
+
for (let pos = 0; pos < len; ) {
|
|
29474
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
29475
|
+
if (take === blockLen) {
|
|
29476
|
+
const dataView = createView2(data);
|
|
29477
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
29478
|
+
this.process(dataView, pos);
|
|
29479
|
+
processed = true;
|
|
29480
|
+
continue;
|
|
29481
|
+
}
|
|
29482
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
29483
|
+
this.pos += take;
|
|
29484
|
+
pos += take;
|
|
29485
|
+
if (this.pos === blockLen) {
|
|
29486
|
+
this.process(view, 0);
|
|
29487
|
+
this.pos = 0;
|
|
29488
|
+
processed = true;
|
|
29489
|
+
}
|
|
29490
|
+
}
|
|
29491
|
+
this.length += data.length;
|
|
29492
|
+
if (processed)
|
|
29493
|
+
this.roundClean();
|
|
29494
|
+
return this;
|
|
29495
|
+
}
|
|
29496
|
+
digestInto(out) {
|
|
29497
|
+
aexists2(this);
|
|
29498
|
+
aoutput2(out, this);
|
|
29499
|
+
this.finished = true;
|
|
29500
|
+
const { buffer, view, blockLen, isLE: isLE2 } = this;
|
|
29501
|
+
let { pos } = this;
|
|
29502
|
+
buffer[pos++] = 128;
|
|
29503
|
+
buffer.fill(0, pos);
|
|
29504
|
+
if (this.padOffset > blockLen - pos) {
|
|
29505
|
+
this.process(view, 0);
|
|
29506
|
+
buffer.fill(0);
|
|
29507
|
+
}
|
|
29508
|
+
setU64FromNum(view, blockLen - 8, this.length * 8, isLE2);
|
|
29509
|
+
this.process(view, 0);
|
|
29510
|
+
this.roundClean();
|
|
29511
|
+
const oview = out === buffer ? view : createView2(out);
|
|
29512
|
+
const len = this.outputLen;
|
|
29513
|
+
const outLen = len / 4;
|
|
29514
|
+
const state = this.get();
|
|
29515
|
+
if (len % 4 || outLen > state.length)
|
|
29516
|
+
throw new Error("invalid outputLen");
|
|
29517
|
+
for (let i = 0; i < outLen; i++)
|
|
29518
|
+
oview.setUint32(4 * i, state[i], isLE2);
|
|
29519
|
+
}
|
|
29520
|
+
digest() {
|
|
29521
|
+
const { buffer, outputLen } = this;
|
|
29522
|
+
this.digestInto(buffer);
|
|
29523
|
+
const res = buffer.slice(0, outputLen);
|
|
29524
|
+
this.destroy();
|
|
29525
|
+
return res;
|
|
29526
|
+
}
|
|
29527
|
+
_cloneIntoMeta(to) {
|
|
29528
|
+
const { buffer, length, finished, destroyed, pos } = this;
|
|
29529
|
+
to.destroyed = destroyed;
|
|
29530
|
+
to.finished = finished;
|
|
29531
|
+
to.length = length;
|
|
29532
|
+
to.pos = pos;
|
|
29533
|
+
if (pos)
|
|
29534
|
+
to.buffer.set(buffer);
|
|
29535
|
+
return to;
|
|
29536
|
+
}
|
|
29537
|
+
clone() {
|
|
29538
|
+
return this._cloneInto();
|
|
29539
|
+
}
|
|
29540
|
+
};
|
|
29541
|
+
SHA256_IV2 = /* @__PURE__ */ Uint32Array.from([
|
|
29542
|
+
1779033703,
|
|
29543
|
+
3144134277,
|
|
29544
|
+
1013904242,
|
|
29545
|
+
2773480762,
|
|
29546
|
+
1359893119,
|
|
29547
|
+
2600822924,
|
|
29548
|
+
528734635,
|
|
29549
|
+
1541459225
|
|
29550
|
+
]);
|
|
29551
|
+
}
|
|
29552
|
+
});
|
|
29553
|
+
|
|
29554
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/sha2.js
|
|
29555
|
+
var SHA256_K, SHA256_W, SHA2_32B, _SHA256, sha2562;
|
|
29556
|
+
var init_sha22 = __esm({
|
|
29557
|
+
"../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/sha2.js"() {
|
|
29558
|
+
init_md2();
|
|
29559
|
+
init_utils3();
|
|
29560
|
+
SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
29561
|
+
1116352408,
|
|
29562
|
+
1899447441,
|
|
29563
|
+
3049323471,
|
|
29564
|
+
3921009573,
|
|
29565
|
+
961987163,
|
|
29566
|
+
1508970993,
|
|
29567
|
+
2453635748,
|
|
29568
|
+
2870763221,
|
|
29569
|
+
3624381080,
|
|
29570
|
+
310598401,
|
|
29571
|
+
607225278,
|
|
29572
|
+
1426881987,
|
|
29573
|
+
1925078388,
|
|
29574
|
+
2162078206,
|
|
29575
|
+
2614888103,
|
|
29576
|
+
3248222580,
|
|
29577
|
+
3835390401,
|
|
29578
|
+
4022224774,
|
|
29579
|
+
264347078,
|
|
29580
|
+
604807628,
|
|
29581
|
+
770255983,
|
|
29582
|
+
1249150122,
|
|
29583
|
+
1555081692,
|
|
29584
|
+
1996064986,
|
|
29585
|
+
2554220882,
|
|
29586
|
+
2821834349,
|
|
29587
|
+
2952996808,
|
|
29588
|
+
3210313671,
|
|
29589
|
+
3336571891,
|
|
29590
|
+
3584528711,
|
|
29591
|
+
113926993,
|
|
29592
|
+
338241895,
|
|
29593
|
+
666307205,
|
|
29594
|
+
773529912,
|
|
29595
|
+
1294757372,
|
|
29596
|
+
1396182291,
|
|
29597
|
+
1695183700,
|
|
29598
|
+
1986661051,
|
|
29599
|
+
2177026350,
|
|
29600
|
+
2456956037,
|
|
29601
|
+
2730485921,
|
|
29602
|
+
2820302411,
|
|
29603
|
+
3259730800,
|
|
29604
|
+
3345764771,
|
|
29605
|
+
3516065817,
|
|
29606
|
+
3600352804,
|
|
29607
|
+
4094571909,
|
|
29608
|
+
275423344,
|
|
29609
|
+
430227734,
|
|
29610
|
+
506948616,
|
|
29611
|
+
659060556,
|
|
29612
|
+
883997877,
|
|
29613
|
+
958139571,
|
|
29614
|
+
1322822218,
|
|
29615
|
+
1537002063,
|
|
29616
|
+
1747873779,
|
|
29617
|
+
1955562222,
|
|
29618
|
+
2024104815,
|
|
29619
|
+
2227730452,
|
|
29620
|
+
2361852424,
|
|
29621
|
+
2428436474,
|
|
29622
|
+
2756734187,
|
|
29623
|
+
3204031479,
|
|
29624
|
+
3329325298
|
|
29625
|
+
]);
|
|
29626
|
+
SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
29627
|
+
SHA2_32B = class extends HashMD2 {
|
|
29628
|
+
// We cannot use array here since array allows indexing by variable
|
|
29629
|
+
// which means optimizer/compiler cannot use registers.
|
|
29630
|
+
// Numeric initializers matter: starting the fields as `undefined` changes
|
|
29631
|
+
// V8's field representation and makes sha256 3x slower (measured).
|
|
29632
|
+
A = 0;
|
|
29633
|
+
B = 0;
|
|
29634
|
+
C = 0;
|
|
29635
|
+
D = 0;
|
|
29636
|
+
E = 0;
|
|
29637
|
+
F = 0;
|
|
29638
|
+
G = 0;
|
|
29639
|
+
H = 0;
|
|
29640
|
+
constructor(outputLen, IV) {
|
|
29641
|
+
super(64, outputLen, 8, false);
|
|
29642
|
+
this.A = IV[0] | 0;
|
|
29643
|
+
this.B = IV[1] | 0;
|
|
29644
|
+
this.C = IV[2] | 0;
|
|
29645
|
+
this.D = IV[3] | 0;
|
|
29646
|
+
this.E = IV[4] | 0;
|
|
29647
|
+
this.F = IV[5] | 0;
|
|
29648
|
+
this.G = IV[6] | 0;
|
|
29649
|
+
this.H = IV[7] | 0;
|
|
29650
|
+
}
|
|
29651
|
+
get() {
|
|
29652
|
+
const { A, B: B2, C: C2, D: D2, E, F, G: G2, H: H3 } = this;
|
|
29653
|
+
return [A, B2, C2, D2, E, F, G2, H3];
|
|
29654
|
+
}
|
|
29655
|
+
// prettier-ignore
|
|
29656
|
+
set(A, B2, C2, D2, E, F, G2, H3) {
|
|
29657
|
+
this.A = A | 0;
|
|
29658
|
+
this.B = B2 | 0;
|
|
29659
|
+
this.C = C2 | 0;
|
|
29660
|
+
this.D = D2 | 0;
|
|
29661
|
+
this.E = E | 0;
|
|
29662
|
+
this.F = F | 0;
|
|
29663
|
+
this.G = G2 | 0;
|
|
29664
|
+
this.H = H3 | 0;
|
|
29665
|
+
}
|
|
29666
|
+
_cloneInto(to) {
|
|
29667
|
+
(to ||= new this.constructor()).set(...this.get());
|
|
29668
|
+
return this._cloneIntoMeta(to);
|
|
29669
|
+
}
|
|
29670
|
+
process(view, offset) {
|
|
29671
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
29672
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
29673
|
+
for (let i = 16; i < 64; i++) {
|
|
29674
|
+
const W15 = SHA256_W[i - 15];
|
|
29675
|
+
const W22 = SHA256_W[i - 2];
|
|
29676
|
+
const s0 = rotr2(W15, 7) ^ rotr2(W15, 18) ^ W15 >>> 3;
|
|
29677
|
+
const s1 = rotr2(W22, 17) ^ rotr2(W22, 19) ^ W22 >>> 10;
|
|
29678
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
29679
|
+
}
|
|
29680
|
+
let { A, B: B2, C: C2, D: D2, E, F, G: G2, H: H3 } = this;
|
|
29681
|
+
for (let i = 0; i < 64; i++) {
|
|
29682
|
+
const sigma1 = rotr2(E, 6) ^ rotr2(E, 11) ^ rotr2(E, 25);
|
|
29683
|
+
const T1 = H3 + sigma1 + Chi2(E, F, G2) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
29684
|
+
const sigma0 = rotr2(A, 2) ^ rotr2(A, 13) ^ rotr2(A, 22);
|
|
29685
|
+
const T2 = sigma0 + Maj2(A, B2, C2) | 0;
|
|
29686
|
+
H3 = G2;
|
|
29687
|
+
G2 = F;
|
|
29688
|
+
F = E;
|
|
29689
|
+
E = D2 + T1 | 0;
|
|
29690
|
+
D2 = C2;
|
|
29691
|
+
C2 = B2;
|
|
29692
|
+
B2 = A;
|
|
29693
|
+
A = T1 + T2 | 0;
|
|
29694
|
+
}
|
|
29695
|
+
A = A + this.A | 0;
|
|
29696
|
+
B2 = B2 + this.B | 0;
|
|
29697
|
+
C2 = C2 + this.C | 0;
|
|
29698
|
+
D2 = D2 + this.D | 0;
|
|
29699
|
+
E = E + this.E | 0;
|
|
29700
|
+
F = F + this.F | 0;
|
|
29701
|
+
G2 = G2 + this.G | 0;
|
|
29702
|
+
H3 = H3 + this.H | 0;
|
|
29703
|
+
this.set(A, B2, C2, D2, E, F, G2, H3);
|
|
29704
|
+
}
|
|
29705
|
+
roundClean() {
|
|
29706
|
+
clean2(SHA256_W);
|
|
29707
|
+
}
|
|
29708
|
+
destroy() {
|
|
29709
|
+
this.destroyed = true;
|
|
29710
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
29711
|
+
clean2(this.buffer);
|
|
29712
|
+
}
|
|
29713
|
+
};
|
|
29714
|
+
_SHA256 = class extends SHA2_32B {
|
|
29715
|
+
constructor() {
|
|
29716
|
+
super(32, SHA256_IV2);
|
|
29717
|
+
}
|
|
29718
|
+
};
|
|
29719
|
+
sha2562 = /* @__PURE__ */ createHasher3(
|
|
29720
|
+
() => new _SHA256(),
|
|
29721
|
+
/* @__PURE__ */ oidNist2(1)
|
|
29722
|
+
);
|
|
29723
|
+
}
|
|
29724
|
+
});
|
|
29725
|
+
|
|
28970
29726
|
// ../e2e/dist/bytes.js
|
|
28971
29727
|
function concatBytes3(...parts) {
|
|
28972
29728
|
let total = 0;
|
|
@@ -29024,11 +29780,11 @@ function base64urlDecode(s) {
|
|
|
29024
29780
|
const lut = new Int16Array(128).fill(-1);
|
|
29025
29781
|
for (let i = 0; i < B64URL.length; i++)
|
|
29026
29782
|
lut[B64URL.charCodeAt(i)] = i;
|
|
29027
|
-
const
|
|
29783
|
+
const clean4 = s.trim();
|
|
29028
29784
|
const out = [];
|
|
29029
29785
|
let buf = 0;
|
|
29030
29786
|
let bits = 0;
|
|
29031
|
-
for (const ch of
|
|
29787
|
+
for (const ch of clean4) {
|
|
29032
29788
|
const code = ch.charCodeAt(0);
|
|
29033
29789
|
const v = code < 128 ? lut[code] : -1;
|
|
29034
29790
|
if (v === void 0 || v < 0)
|
|
@@ -29087,17 +29843,17 @@ var UUID_LABEL_LENGTH;
|
|
|
29087
29843
|
var init_identity = __esm({
|
|
29088
29844
|
"../e2e/dist/identity.js"() {
|
|
29089
29845
|
init_ed25519();
|
|
29090
|
-
|
|
29846
|
+
init_sha22();
|
|
29091
29847
|
init_bytes();
|
|
29092
29848
|
UUID_LABEL_LENGTH = 16;
|
|
29093
29849
|
}
|
|
29094
29850
|
});
|
|
29095
29851
|
|
|
29096
|
-
// ../../node_modules/.pnpm/@noble+hashes@2.
|
|
29852
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/hmac.js
|
|
29097
29853
|
var _HMAC, hmac;
|
|
29098
29854
|
var init_hmac = __esm({
|
|
29099
|
-
"../../node_modules/.pnpm/@noble+hashes@2.
|
|
29100
|
-
|
|
29855
|
+
"../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/hmac.js"() {
|
|
29856
|
+
init_utils3();
|
|
29101
29857
|
_HMAC = class {
|
|
29102
29858
|
oHash;
|
|
29103
29859
|
iHash;
|
|
@@ -29108,10 +29864,10 @@ var init_hmac = __esm({
|
|
|
29108
29864
|
destroyed = false;
|
|
29109
29865
|
constructor(hash, key) {
|
|
29110
29866
|
ahash(hash);
|
|
29111
|
-
|
|
29867
|
+
abytes3(key, void 0, "key");
|
|
29112
29868
|
this.iHash = hash.create();
|
|
29113
29869
|
if (typeof this.iHash.update !== "function")
|
|
29114
|
-
throw new Error("
|
|
29870
|
+
throw new Error("expected Hash instance");
|
|
29115
29871
|
this.blockLen = this.iHash.blockLen;
|
|
29116
29872
|
this.outputLen = this.iHash.outputLen;
|
|
29117
29873
|
const blockLen = this.blockLen;
|
|
@@ -29124,16 +29880,16 @@ var init_hmac = __esm({
|
|
|
29124
29880
|
for (let i = 0; i < pad.length; i++)
|
|
29125
29881
|
pad[i] ^= 54 ^ 92;
|
|
29126
29882
|
this.oHash.update(pad);
|
|
29127
|
-
|
|
29883
|
+
clean2(pad);
|
|
29128
29884
|
}
|
|
29129
29885
|
update(buf) {
|
|
29130
|
-
|
|
29886
|
+
aexists2(this);
|
|
29131
29887
|
this.iHash.update(buf);
|
|
29132
29888
|
return this;
|
|
29133
29889
|
}
|
|
29134
29890
|
digestInto(out) {
|
|
29135
|
-
|
|
29136
|
-
|
|
29891
|
+
aexists2(this);
|
|
29892
|
+
aoutput2(out, this);
|
|
29137
29893
|
this.finished = true;
|
|
29138
29894
|
const buf = out.subarray(0, this.outputLen);
|
|
29139
29895
|
this.iHash.digestInto(buf);
|
|
@@ -29148,12 +29904,13 @@ var init_hmac = __esm({
|
|
|
29148
29904
|
}
|
|
29149
29905
|
_cloneInto(to) {
|
|
29150
29906
|
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
29151
|
-
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
29907
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen, canXOF } = this;
|
|
29152
29908
|
to = to;
|
|
29153
29909
|
to.finished = finished;
|
|
29154
29910
|
to.destroyed = destroyed;
|
|
29155
29911
|
to.blockLen = blockLen;
|
|
29156
29912
|
to.outputLen = outputLen;
|
|
29913
|
+
to.canXOF = canXOF;
|
|
29157
29914
|
to.oHash = oHash._cloneInto(to.oHash);
|
|
29158
29915
|
to.iHash = iHash._cloneInto(to.iHash);
|
|
29159
29916
|
return to;
|
|
@@ -29175,17 +29932,11 @@ var init_hmac = __esm({
|
|
|
29175
29932
|
}
|
|
29176
29933
|
});
|
|
29177
29934
|
|
|
29178
|
-
// ../../node_modules/.pnpm/@noble+hashes@2.
|
|
29179
|
-
function
|
|
29180
|
-
ahash(hash);
|
|
29181
|
-
if (salt === void 0)
|
|
29182
|
-
salt = new Uint8Array(hash.outputLen);
|
|
29183
|
-
return hmac(hash, salt, ikm);
|
|
29184
|
-
}
|
|
29185
|
-
function expand2(hash, prk, info, length = 32) {
|
|
29935
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/hkdf.js
|
|
29936
|
+
function expand2(hash, prk, info, length = 32, _recycled) {
|
|
29186
29937
|
ahash(hash);
|
|
29187
|
-
|
|
29188
|
-
|
|
29938
|
+
anumber3(length, "length");
|
|
29939
|
+
abytes3(prk, void 0, "prk");
|
|
29189
29940
|
const olen = hash.outputLen;
|
|
29190
29941
|
if (prk.length < olen)
|
|
29191
29942
|
throw new Error('"prk" must be at least HashLen octets');
|
|
@@ -29195,30 +29946,57 @@ function expand2(hash, prk, info, length = 32) {
|
|
|
29195
29946
|
if (info === void 0)
|
|
29196
29947
|
info = EMPTY_BUFFER;
|
|
29197
29948
|
else
|
|
29198
|
-
|
|
29199
|
-
|
|
29200
|
-
|
|
29201
|
-
|
|
29202
|
-
|
|
29203
|
-
|
|
29949
|
+
abytes3(info, void 0, "info");
|
|
29950
|
+
if (!blocks) {
|
|
29951
|
+
if (_recycled)
|
|
29952
|
+
clean2(prk);
|
|
29953
|
+
return new Uint8Array();
|
|
29954
|
+
}
|
|
29955
|
+
const okm = _recycled && blocks === 1 ? prk : new Uint8Array(blocks * olen);
|
|
29956
|
+
const { iHash, oHash } = hmac.create(hash, prk);
|
|
29957
|
+
const T2 = _recycled ? prk : new Uint8Array(olen);
|
|
29958
|
+
const worker = blocks > 1 ? _recycled?.iHash || hash.create() : void 0;
|
|
29959
|
+
for (let counter = 0; counter < blocks - 1; counter++) {
|
|
29204
29960
|
HKDF_COUNTER[0] = counter + 1;
|
|
29205
|
-
|
|
29961
|
+
const iWork = iHash._cloneInto(worker);
|
|
29962
|
+
if (counter)
|
|
29963
|
+
iWork.update(T2);
|
|
29964
|
+
iWork.update(info).update(HKDF_COUNTER).digestInto(T2);
|
|
29965
|
+
oHash._cloneInto(worker).update(T2).digestInto(T2);
|
|
29206
29966
|
okm.set(T2, olen * counter);
|
|
29207
|
-
HMAC._cloneInto(HMACTmp);
|
|
29208
29967
|
}
|
|
29209
|
-
|
|
29210
|
-
|
|
29211
|
-
|
|
29212
|
-
|
|
29968
|
+
HKDF_COUNTER[0] = blocks;
|
|
29969
|
+
if (blocks > 1)
|
|
29970
|
+
iHash.update(T2);
|
|
29971
|
+
iHash.update(info).update(HKDF_COUNTER).digestInto(T2);
|
|
29972
|
+
oHash.update(T2).digestInto(T2);
|
|
29973
|
+
okm.set(T2, olen * (blocks - 1));
|
|
29974
|
+
iHash.destroy();
|
|
29975
|
+
oHash.destroy();
|
|
29976
|
+
worker?.destroy();
|
|
29977
|
+
if (T2 !== okm)
|
|
29978
|
+
clean2(T2);
|
|
29979
|
+
clean2(HKDF_COUNTER);
|
|
29980
|
+
if (length === okm.length)
|
|
29981
|
+
return okm;
|
|
29982
|
+
const res = okm.slice(0, length);
|
|
29983
|
+
clean2(okm);
|
|
29984
|
+
return res;
|
|
29213
29985
|
}
|
|
29214
29986
|
var HKDF_COUNTER, EMPTY_BUFFER, hkdf;
|
|
29215
29987
|
var init_hkdf = __esm({
|
|
29216
|
-
"../../node_modules/.pnpm/@noble+hashes@2.
|
|
29988
|
+
"../../node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/hkdf.js"() {
|
|
29217
29989
|
init_hmac();
|
|
29218
|
-
|
|
29990
|
+
init_utils3();
|
|
29219
29991
|
HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
|
|
29220
29992
|
EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
29221
|
-
hkdf = (hash, ikm, salt, info, length) =>
|
|
29993
|
+
hkdf = (hash, ikm, salt, info, length) => {
|
|
29994
|
+
ahash(hash);
|
|
29995
|
+
if (salt === void 0)
|
|
29996
|
+
salt = new Uint8Array(hash.outputLen);
|
|
29997
|
+
const HMAC = hmac.create(hash, salt).update(ikm);
|
|
29998
|
+
return expand2(hash, HMAC.digest(), info, length, HMAC);
|
|
29999
|
+
};
|
|
29222
30000
|
}
|
|
29223
30001
|
});
|
|
29224
30002
|
|
|
@@ -29237,7 +30015,7 @@ function respond(clientHello, identity) {
|
|
|
29237
30015
|
const ephIPub = clientHello.slice(0, X_PUB);
|
|
29238
30016
|
const nC = clientHello.slice(X_PUB, X_PUB + HS_NONCE);
|
|
29239
30017
|
const { secretKey: ephSecret, publicKey: ephRPub } = x25519.keygen();
|
|
29240
|
-
const nS =
|
|
30018
|
+
const nS = randomBytes5(HS_NONCE);
|
|
29241
30019
|
const sig = sign(transcript(ephIPub, ephRPub, nC, nS), identity.secretKey);
|
|
29242
30020
|
const shared = x25519.getSharedSecret(ephSecret, ephIPub);
|
|
29243
30021
|
const { i2r, r2i } = deriveKeys(shared, nC, nS);
|
|
@@ -29251,8 +30029,8 @@ var init_handshake = __esm({
|
|
|
29251
30029
|
"../e2e/dist/handshake.js"() {
|
|
29252
30030
|
init_ed25519();
|
|
29253
30031
|
init_hkdf();
|
|
29254
|
-
|
|
29255
|
-
|
|
30032
|
+
init_sha22();
|
|
30033
|
+
init_utils3();
|
|
29256
30034
|
init_bytes();
|
|
29257
30035
|
init_identity();
|
|
29258
30036
|
LABEL = utf8("moxxy/proxy-e2e/v1");
|
|
@@ -29263,21 +30041,21 @@ var init_handshake = __esm({
|
|
|
29263
30041
|
});
|
|
29264
30042
|
|
|
29265
30043
|
// ../../node_modules/.pnpm/@noble+ciphers@2.2.0/node_modules/@noble/ciphers/utils.js
|
|
29266
|
-
function
|
|
30044
|
+
function isBytes4(a) {
|
|
29267
30045
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
29268
30046
|
}
|
|
29269
30047
|
function abool2(b) {
|
|
29270
30048
|
if (typeof b !== "boolean")
|
|
29271
30049
|
throw new TypeError(`boolean expected, not ${b}`);
|
|
29272
30050
|
}
|
|
29273
|
-
function
|
|
30051
|
+
function anumber4(n) {
|
|
29274
30052
|
if (typeof n !== "number")
|
|
29275
30053
|
throw new TypeError("number expected, got " + typeof n);
|
|
29276
30054
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
29277
30055
|
throw new RangeError("positive integer expected, got " + n);
|
|
29278
30056
|
}
|
|
29279
|
-
function
|
|
29280
|
-
const bytes =
|
|
30057
|
+
function abytes4(value2, length, title = "") {
|
|
30058
|
+
const bytes = isBytes4(value2);
|
|
29281
30059
|
const len = value2?.length;
|
|
29282
30060
|
const needsLen = length !== void 0;
|
|
29283
30061
|
if (!bytes || needsLen && len !== length) {
|
|
@@ -29291,14 +30069,14 @@ function abytes3(value2, length, title = "") {
|
|
|
29291
30069
|
}
|
|
29292
30070
|
return value2;
|
|
29293
30071
|
}
|
|
29294
|
-
function
|
|
30072
|
+
function aexists3(instance, checkFinished = true) {
|
|
29295
30073
|
if (instance.destroyed)
|
|
29296
30074
|
throw new Error("Hash instance has been destroyed");
|
|
29297
30075
|
if (checkFinished && instance.finished)
|
|
29298
30076
|
throw new Error("Hash#digest() has already been called");
|
|
29299
30077
|
}
|
|
29300
|
-
function
|
|
29301
|
-
|
|
30078
|
+
function aoutput3(out, instance, onlyAligned = false) {
|
|
30079
|
+
abytes4(out, void 0, "output");
|
|
29302
30080
|
const min = instance.outputLen;
|
|
29303
30081
|
if (out.length < min) {
|
|
29304
30082
|
throw new RangeError("digestInto() expects output buffer of length at least " + min);
|
|
@@ -29309,15 +30087,15 @@ function aoutput2(out, instance, onlyAligned = false) {
|
|
|
29309
30087
|
function u32(arr) {
|
|
29310
30088
|
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
29311
30089
|
}
|
|
29312
|
-
function
|
|
30090
|
+
function clean3(...arrays) {
|
|
29313
30091
|
for (let i = 0; i < arrays.length; i++) {
|
|
29314
30092
|
arrays[i].fill(0);
|
|
29315
30093
|
}
|
|
29316
30094
|
}
|
|
29317
|
-
function
|
|
30095
|
+
function createView3(arr) {
|
|
29318
30096
|
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
29319
30097
|
}
|
|
29320
|
-
function
|
|
30098
|
+
function checkOpts2(defaults, opts) {
|
|
29321
30099
|
if (opts == null || typeof opts !== "object")
|
|
29322
30100
|
throw new Error("options must be defined");
|
|
29323
30101
|
const merged = Object.assign(defaults, opts);
|
|
@@ -29344,7 +30122,7 @@ function wrapMacConstructor(keyLen, macCons, fromMsg) {
|
|
|
29344
30122
|
function getOutput(expectedLength, out, onlyAligned = true) {
|
|
29345
30123
|
if (out === void 0)
|
|
29346
30124
|
return new Uint8Array(expectedLength);
|
|
29347
|
-
|
|
30125
|
+
abytes4(out, void 0, "output");
|
|
29348
30126
|
if (out.length !== expectedLength)
|
|
29349
30127
|
throw new Error('"output" expected Uint8Array of length ' + expectedLength + ", got: " + out.length);
|
|
29350
30128
|
if (onlyAligned && !isAligned32(out))
|
|
@@ -29352,11 +30130,11 @@ function getOutput(expectedLength, out, onlyAligned = true) {
|
|
|
29352
30130
|
return out;
|
|
29353
30131
|
}
|
|
29354
30132
|
function u64Lengths(dataLength, aadLength, isLE2) {
|
|
29355
|
-
|
|
29356
|
-
|
|
30133
|
+
anumber4(dataLength);
|
|
30134
|
+
anumber4(aadLength);
|
|
29357
30135
|
abool2(isLE2);
|
|
29358
30136
|
const num = new Uint8Array(16);
|
|
29359
|
-
const view =
|
|
30137
|
+
const view = createView3(num);
|
|
29360
30138
|
view.setBigUint64(0, BigInt(aadLength), isLE2);
|
|
29361
30139
|
view.setBigUint64(8, BigInt(dataLength), isLE2);
|
|
29362
30140
|
return num;
|
|
@@ -29365,10 +30143,10 @@ function isAligned32(bytes) {
|
|
|
29365
30143
|
return bytes.byteOffset % 4 === 0;
|
|
29366
30144
|
}
|
|
29367
30145
|
function copyBytes2(bytes) {
|
|
29368
|
-
return Uint8Array.from(
|
|
30146
|
+
return Uint8Array.from(abytes4(bytes));
|
|
29369
30147
|
}
|
|
29370
30148
|
var isLE, byteSwap, swap8IfBE, byteSwap32, swap32IfBE, wrapCipher;
|
|
29371
|
-
var
|
|
30149
|
+
var init_utils4 = __esm({
|
|
29372
30150
|
"../../node_modules/.pnpm/@noble+ciphers@2.2.0/node_modules/@noble/ciphers/utils.js"() {
|
|
29373
30151
|
isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
29374
30152
|
byteSwap = (word) => word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
@@ -29381,20 +30159,20 @@ var init_utils3 = __esm({
|
|
|
29381
30159
|
swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
29382
30160
|
wrapCipher = /* @__NO_SIDE_EFFECTS__ */ (params, constructor) => {
|
|
29383
30161
|
function wrappedCipher(key, ...args) {
|
|
29384
|
-
|
|
30162
|
+
abytes4(key, void 0, "key");
|
|
29385
30163
|
if (params.nonceLength !== void 0) {
|
|
29386
30164
|
const nonce = args[0];
|
|
29387
|
-
|
|
30165
|
+
abytes4(nonce, params.varSizeNonce ? void 0 : params.nonceLength, "nonce");
|
|
29388
30166
|
}
|
|
29389
30167
|
const tagl = params.tagLength;
|
|
29390
30168
|
if (tagl && args[1] !== void 0)
|
|
29391
|
-
|
|
30169
|
+
abytes4(args[1], void 0, "AAD");
|
|
29392
30170
|
const cipher = constructor(key, ...args);
|
|
29393
30171
|
const checkOutput = (fnLength, output) => {
|
|
29394
30172
|
if (output !== void 0) {
|
|
29395
30173
|
if (fnLength !== 2)
|
|
29396
30174
|
throw new Error("cipher output not supported");
|
|
29397
|
-
|
|
30175
|
+
abytes4(output, void 0, "output");
|
|
29398
30176
|
}
|
|
29399
30177
|
};
|
|
29400
30178
|
let called = false;
|
|
@@ -29403,12 +30181,12 @@ var init_utils3 = __esm({
|
|
|
29403
30181
|
if (called)
|
|
29404
30182
|
throw new Error("cannot encrypt() twice with same key + nonce");
|
|
29405
30183
|
called = true;
|
|
29406
|
-
|
|
30184
|
+
abytes4(data);
|
|
29407
30185
|
checkOutput(cipher.encrypt.length, output);
|
|
29408
30186
|
return cipher.encrypt(data, output);
|
|
29409
30187
|
},
|
|
29410
30188
|
decrypt(data, output) {
|
|
29411
|
-
|
|
30189
|
+
abytes4(data);
|
|
29412
30190
|
if (tagl && data.length < tagl)
|
|
29413
30191
|
throw new Error('"ciphertext" expected length bigger than tagLength=' + tagl);
|
|
29414
30192
|
checkOutput(cipher.decrypt.length, output);
|
|
@@ -29473,20 +30251,20 @@ function runCipher(core, sigma, key, nonce, data, output, counter, rounds) {
|
|
|
29473
30251
|
}
|
|
29474
30252
|
}
|
|
29475
30253
|
function createCipher(core, opts) {
|
|
29476
|
-
const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } =
|
|
30254
|
+
const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = checkOpts2({ allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 }, opts);
|
|
29477
30255
|
if (typeof core !== "function")
|
|
29478
30256
|
throw new Error("core must be a function");
|
|
29479
|
-
|
|
29480
|
-
|
|
30257
|
+
anumber4(counterLength);
|
|
30258
|
+
anumber4(rounds);
|
|
29481
30259
|
abool2(counterRight);
|
|
29482
30260
|
abool2(allowShortKeys);
|
|
29483
30261
|
return (key, nonce, data, output, counter = 0) => {
|
|
29484
|
-
|
|
29485
|
-
|
|
29486
|
-
|
|
30262
|
+
abytes4(key, void 0, "key");
|
|
30263
|
+
abytes4(nonce, void 0, "nonce");
|
|
30264
|
+
abytes4(data, void 0, "data");
|
|
29487
30265
|
const len = data.length;
|
|
29488
30266
|
output = getOutput(len, output, false);
|
|
29489
|
-
|
|
30267
|
+
anumber4(counter);
|
|
29490
30268
|
if (counter < 0 || counter >= MAX_COUNTER)
|
|
29491
30269
|
throw new Error("arx: counter overflow");
|
|
29492
30270
|
const toClean = [];
|
|
@@ -29503,7 +30281,7 @@ function createCipher(core, opts) {
|
|
|
29503
30281
|
sigma = sigma16_32;
|
|
29504
30282
|
toClean.push(k2);
|
|
29505
30283
|
} else {
|
|
29506
|
-
|
|
30284
|
+
abytes4(key, 32, "arx key");
|
|
29507
30285
|
throw new Error("invalid key size");
|
|
29508
30286
|
}
|
|
29509
30287
|
if (!isLE || !isAligned32(nonce))
|
|
@@ -29518,7 +30296,7 @@ function createCipher(core, opts) {
|
|
|
29518
30296
|
else {
|
|
29519
30297
|
const sigmaRaw = swap32IfBE(Uint32Array.from(sigma));
|
|
29520
30298
|
extendNonceFn(sigmaRaw, k32, u32(n16), k32);
|
|
29521
|
-
|
|
30299
|
+
clean3(sigmaRaw);
|
|
29522
30300
|
swap32IfBE(k32);
|
|
29523
30301
|
}
|
|
29524
30302
|
nonce = nonce.subarray(16);
|
|
@@ -29538,14 +30316,14 @@ function createCipher(core, opts) {
|
|
|
29538
30316
|
runCipher(core, sigma, k32, n32, data, output, counter, rounds);
|
|
29539
30317
|
return output;
|
|
29540
30318
|
} finally {
|
|
29541
|
-
|
|
30319
|
+
clean3(...toClean);
|
|
29542
30320
|
}
|
|
29543
30321
|
};
|
|
29544
30322
|
}
|
|
29545
30323
|
var encodeStr, sigma16_32, sigma32_32, BLOCK_LEN, BLOCK_LEN32, MAX_COUNTER, U32_EMPTY;
|
|
29546
30324
|
var init_arx = __esm({
|
|
29547
30325
|
"../../node_modules/.pnpm/@noble+ciphers@2.2.0/node_modules/@noble/ciphers/_arx.js"() {
|
|
29548
|
-
|
|
30326
|
+
init_utils4();
|
|
29549
30327
|
encodeStr = (str) => Uint8Array.from(str.split(""), (c) => c.charCodeAt(0));
|
|
29550
30328
|
sigma16_32 = /* @__PURE__ */ (() => swap32IfBE(u32(encodeStr("expand 16-byte k"))))();
|
|
29551
30329
|
sigma32_32 = /* @__PURE__ */ (() => swap32IfBE(u32(encodeStr("expand 32-byte k"))))();
|
|
@@ -29563,7 +30341,7 @@ function u8to16(a, i) {
|
|
|
29563
30341
|
var Poly1305, poly1305;
|
|
29564
30342
|
var init_poly1305 = __esm({
|
|
29565
30343
|
"../../node_modules/.pnpm/@noble+ciphers@2.2.0/node_modules/@noble/ciphers/_poly1305.js"() {
|
|
29566
|
-
|
|
30344
|
+
init_utils4();
|
|
29567
30345
|
Poly1305 = class {
|
|
29568
30346
|
blockLen = 16;
|
|
29569
30347
|
outputLen = 16;
|
|
@@ -29577,7 +30355,7 @@ var init_poly1305 = __esm({
|
|
|
29577
30355
|
destroyed = false;
|
|
29578
30356
|
// Can be speed-up using BigUint64Array, at the cost of complexity
|
|
29579
30357
|
constructor(key) {
|
|
29580
|
-
key = copyBytes2(
|
|
30358
|
+
key = copyBytes2(abytes4(key, 32, "key"));
|
|
29581
30359
|
const t0 = u8to16(key, 0);
|
|
29582
30360
|
const t1 = u8to16(key, 2);
|
|
29583
30361
|
const t2 = u8to16(key, 4);
|
|
@@ -29753,11 +30531,11 @@ var init_poly1305 = __esm({
|
|
|
29753
30531
|
f = (h[i] + pad[i] | 0) + (f >>> 16) | 0;
|
|
29754
30532
|
h[i] = f & 65535;
|
|
29755
30533
|
}
|
|
29756
|
-
|
|
30534
|
+
clean3(g);
|
|
29757
30535
|
}
|
|
29758
30536
|
update(data) {
|
|
29759
|
-
|
|
29760
|
-
|
|
30537
|
+
aexists3(this);
|
|
30538
|
+
abytes4(data);
|
|
29761
30539
|
data = copyBytes2(data);
|
|
29762
30540
|
const { buffer, blockLen } = this;
|
|
29763
30541
|
const len = data.length;
|
|
@@ -29780,11 +30558,11 @@ var init_poly1305 = __esm({
|
|
|
29780
30558
|
}
|
|
29781
30559
|
destroy() {
|
|
29782
30560
|
this.destroyed = true;
|
|
29783
|
-
|
|
30561
|
+
clean3(this.h, this.r, this.buffer, this.pad);
|
|
29784
30562
|
}
|
|
29785
30563
|
digestInto(out) {
|
|
29786
|
-
|
|
29787
|
-
|
|
30564
|
+
aexists3(this);
|
|
30565
|
+
aoutput3(out, this);
|
|
29788
30566
|
this.finished = true;
|
|
29789
30567
|
const { buffer, h } = this;
|
|
29790
30568
|
let { pos } = this;
|
|
@@ -29982,7 +30760,7 @@ function hchacha(s, k2, i, out) {
|
|
|
29982
30760
|
}
|
|
29983
30761
|
function computeTag(fn, key, nonce, ciphertext, AAD) {
|
|
29984
30762
|
if (AAD !== void 0)
|
|
29985
|
-
|
|
30763
|
+
abytes4(AAD, void 0, "AAD");
|
|
29986
30764
|
const authKey = fn(key, nonce, ZEROS32);
|
|
29987
30765
|
const lengths = u64Lengths(ciphertext.length, AAD ? AAD.length : 0, true);
|
|
29988
30766
|
const h = poly1305.create(authKey);
|
|
@@ -29991,7 +30769,7 @@ function computeTag(fn, key, nonce, ciphertext, AAD) {
|
|
|
29991
30769
|
updatePadded(h, ciphertext);
|
|
29992
30770
|
h.update(lengths);
|
|
29993
30771
|
const res = h.digest();
|
|
29994
|
-
|
|
30772
|
+
clean3(authKey, lengths);
|
|
29995
30773
|
return res;
|
|
29996
30774
|
}
|
|
29997
30775
|
var xchacha20, ZEROS16, updatePadded, ZEROS32, _poly1305_aead, xchacha20poly1305;
|
|
@@ -29999,7 +30777,7 @@ var init_chacha = __esm({
|
|
|
29999
30777
|
"../../node_modules/.pnpm/@noble+ciphers@2.2.0/node_modules/@noble/ciphers/chacha.js"() {
|
|
30000
30778
|
init_arx();
|
|
30001
30779
|
init_poly1305();
|
|
30002
|
-
|
|
30780
|
+
init_utils4();
|
|
30003
30781
|
xchacha20 = /* @__PURE__ */ createCipher(chachaCore, {
|
|
30004
30782
|
counterRight: false,
|
|
30005
30783
|
counterLength: 8,
|
|
@@ -30025,7 +30803,7 @@ var init_chacha = __esm({
|
|
|
30025
30803
|
xorStream(key, nonce, oPlain, oPlain, 1);
|
|
30026
30804
|
const tag2 = computeTag(xorStream, key, nonce, oPlain, AAD);
|
|
30027
30805
|
output.set(tag2, plength);
|
|
30028
|
-
|
|
30806
|
+
clean3(tag2);
|
|
30029
30807
|
return output;
|
|
30030
30808
|
},
|
|
30031
30809
|
decrypt(ciphertext, output) {
|
|
@@ -30034,12 +30812,12 @@ var init_chacha = __esm({
|
|
|
30034
30812
|
const passedTag = ciphertext.subarray(-tagLength);
|
|
30035
30813
|
const tag2 = computeTag(xorStream, key, nonce, data, AAD);
|
|
30036
30814
|
if (!equalBytes2(passedTag, tag2)) {
|
|
30037
|
-
|
|
30815
|
+
clean3(tag2);
|
|
30038
30816
|
throw new Error("invalid tag");
|
|
30039
30817
|
}
|
|
30040
30818
|
output.set(ciphertext.subarray(0, -tagLength));
|
|
30041
30819
|
xorStream(key, nonce, output, output, 1);
|
|
30042
|
-
|
|
30820
|
+
clean3(tag2);
|
|
30043
30821
|
return output;
|
|
30044
30822
|
}
|
|
30045
30823
|
};
|
|
@@ -30056,7 +30834,7 @@ var SEQ, NONCE, HEADER, FrameSealer, FrameOpener;
|
|
|
30056
30834
|
var init_frame = __esm({
|
|
30057
30835
|
"../e2e/dist/frame.js"() {
|
|
30058
30836
|
init_chacha();
|
|
30059
|
-
|
|
30837
|
+
init_utils3();
|
|
30060
30838
|
init_bytes();
|
|
30061
30839
|
SEQ = 8;
|
|
30062
30840
|
NONCE = 24;
|
|
@@ -30069,7 +30847,7 @@ var init_frame = __esm({
|
|
|
30069
30847
|
}
|
|
30070
30848
|
seal(plaintext) {
|
|
30071
30849
|
const seqBytes = u64be(this.seq);
|
|
30072
|
-
const nonce =
|
|
30850
|
+
const nonce = randomBytes5(NONCE);
|
|
30073
30851
|
const ct3 = xchacha20poly1305(this.key, nonce, seqBytes).encrypt(plaintext);
|
|
30074
30852
|
this.seq += 1;
|
|
30075
30853
|
return concatBytes3(seqBytes, nonce, ct3);
|
|
@@ -30189,7 +30967,7 @@ async function loadOrCreateIdentity(path72 = defaultIdentityPath()) {
|
|
|
30189
30967
|
}
|
|
30190
30968
|
if (hex !== null) {
|
|
30191
30969
|
try {
|
|
30192
|
-
const secretKey =
|
|
30970
|
+
const secretKey = hexToBytes3(hex);
|
|
30193
30971
|
if (secretKey.length === 32) {
|
|
30194
30972
|
return { secretKey, publicKey: publicKeyFromSecret(secretKey) };
|
|
30195
30973
|
}
|
|
@@ -30197,12 +30975,12 @@ async function loadOrCreateIdentity(path72 = defaultIdentityPath()) {
|
|
|
30197
30975
|
}
|
|
30198
30976
|
}
|
|
30199
30977
|
const identity = generateIdentity();
|
|
30200
|
-
await writeFileAtomic(path72,
|
|
30978
|
+
await writeFileAtomic(path72, bytesToHex3(identity.secretKey), { mode: 384 });
|
|
30201
30979
|
return identity;
|
|
30202
30980
|
}
|
|
30203
30981
|
var init_node2 = __esm({
|
|
30204
30982
|
"../e2e/dist/node.js"() {
|
|
30205
|
-
|
|
30983
|
+
init_utils3();
|
|
30206
30984
|
init_identity();
|
|
30207
30985
|
}
|
|
30208
30986
|
});
|
|
@@ -32445,7 +33223,7 @@ var require_websocket = __commonJS({
|
|
|
32445
33223
|
var http = __require("http");
|
|
32446
33224
|
var net3 = __require("net");
|
|
32447
33225
|
var tls = __require("tls");
|
|
32448
|
-
var { randomBytes:
|
|
33226
|
+
var { randomBytes: randomBytes9, createHash: createHash10 } = __require("crypto");
|
|
32449
33227
|
var { Duplex, Readable } = __require("stream");
|
|
32450
33228
|
var { URL: URL2 } = __require("url");
|
|
32451
33229
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -32983,7 +33761,7 @@ var require_websocket = __commonJS({
|
|
|
32983
33761
|
}
|
|
32984
33762
|
}
|
|
32985
33763
|
const defaultPort = isSecure ? 443 : 80;
|
|
32986
|
-
const key =
|
|
33764
|
+
const key = randomBytes9(16).toString("base64");
|
|
32987
33765
|
const request = isSecure ? https.request : http.request;
|
|
32988
33766
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
32989
33767
|
let perMessageDeflate;
|
|
@@ -33113,7 +33891,7 @@ var require_websocket = __commonJS({
|
|
|
33113
33891
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
33114
33892
|
return;
|
|
33115
33893
|
}
|
|
33116
|
-
const digest =
|
|
33894
|
+
const digest = createHash10("sha1").update(key + GUID).digest("base64");
|
|
33117
33895
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
33118
33896
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
33119
33897
|
return;
|
|
@@ -33479,7 +34257,7 @@ var require_websocket_server = __commonJS({
|
|
|
33479
34257
|
var EventEmitter3 = __require("events");
|
|
33480
34258
|
var http = __require("http");
|
|
33481
34259
|
var { Duplex } = __require("stream");
|
|
33482
|
-
var { createHash:
|
|
34260
|
+
var { createHash: createHash10 } = __require("crypto");
|
|
33483
34261
|
var extension2 = require_extension();
|
|
33484
34262
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
33485
34263
|
var subprotocol2 = require_subprotocol();
|
|
@@ -33786,7 +34564,7 @@ var require_websocket_server = __commonJS({
|
|
|
33786
34564
|
);
|
|
33787
34565
|
}
|
|
33788
34566
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
33789
|
-
const digest =
|
|
34567
|
+
const digest = createHash10("sha1").update(key + GUID).digest("base64");
|
|
33790
34568
|
const headers = [
|
|
33791
34569
|
"HTTP/1.1 101 Switching Protocols",
|
|
33792
34570
|
"Upgrade: websocket",
|
|
@@ -34080,7 +34858,7 @@ var init_provider = __esm({
|
|
|
34080
34858
|
scheduleReconnect() {
|
|
34081
34859
|
if (this.closed || this.reconnectTimer || this.targets.size === 0)
|
|
34082
34860
|
return;
|
|
34083
|
-
const
|
|
34861
|
+
const delay4 = this.reconnectMs;
|
|
34084
34862
|
this.reconnectMs = Math.min(this.reconnectMs * 2, RECONNECT_MAX_MS);
|
|
34085
34863
|
this.reconnectTimer = setTimeout(() => {
|
|
34086
34864
|
this.reconnectTimer = null;
|
|
@@ -34088,7 +34866,7 @@ var init_provider = __esm({
|
|
|
34088
34866
|
return;
|
|
34089
34867
|
this.connectControl().then(() => this.logger?.info?.("proxy: control reconnected")).catch(() => {
|
|
34090
34868
|
});
|
|
34091
|
-
},
|
|
34869
|
+
}, delay4);
|
|
34092
34870
|
this.reconnectTimer.unref?.();
|
|
34093
34871
|
}
|
|
34094
34872
|
/** Pipe one inbound peer (raw bytes over a `/data` WS) to its target's port. */
|
|
@@ -38944,8 +39722,8 @@ function warnWindowsPipeAclOnce(logger, pipePath) {
|
|
|
38944
39722
|
async function reclaimStaleSocket(socketPath) {
|
|
38945
39723
|
if (!fs35__default.existsSync(socketPath))
|
|
38946
39724
|
return;
|
|
38947
|
-
const
|
|
38948
|
-
if (
|
|
39725
|
+
const alive2 = await isRunnerUp(socketPath);
|
|
39726
|
+
if (alive2)
|
|
38949
39727
|
return;
|
|
38950
39728
|
if (await isRunnerUp(socketPath))
|
|
38951
39729
|
return;
|
|
@@ -39069,6 +39847,37 @@ var init_unix_socket = __esm({
|
|
|
39069
39847
|
warnedWindowsPipeAcl = false;
|
|
39070
39848
|
}
|
|
39071
39849
|
});
|
|
39850
|
+
async function handleComputerApprovalFocus({ session }, raw) {
|
|
39851
|
+
const command = computerApprovalFocusSchema.parse(raw);
|
|
39852
|
+
if (command.sessionId !== session.id)
|
|
39853
|
+
throw new Error("Computer Use session mismatch");
|
|
39854
|
+
const service = session.computerControl;
|
|
39855
|
+
if (service?.approvalFocus)
|
|
39856
|
+
await service.approvalFocus(command);
|
|
39857
|
+
}
|
|
39858
|
+
async function handleComputerSnapshot({ session }, raw) {
|
|
39859
|
+
z$1.object({}).strict().parse(raw);
|
|
39860
|
+
const service = session.computerControl;
|
|
39861
|
+
if (!service)
|
|
39862
|
+
return [];
|
|
39863
|
+
const snapshots = z$1.array(computerControlSnapshotSchema).max(256).parse(await service.snapshot());
|
|
39864
|
+
if (snapshots.some((snapshot) => snapshot.sessionId !== session.id))
|
|
39865
|
+
throw new Error("Computer Use session mismatch");
|
|
39866
|
+
return snapshots;
|
|
39867
|
+
}
|
|
39868
|
+
async function handleComputerControl({ session }, raw) {
|
|
39869
|
+
const command = computerControlCommandSchema.parse(raw);
|
|
39870
|
+
if (command.sessionId !== session.id)
|
|
39871
|
+
throw new Error("Computer Use session mismatch");
|
|
39872
|
+
const service = session.computerControl;
|
|
39873
|
+
if (!service)
|
|
39874
|
+
throw new Error("Computer Use control is not supported by this session");
|
|
39875
|
+
await service.control(command);
|
|
39876
|
+
}
|
|
39877
|
+
var init_computer_handlers = __esm({
|
|
39878
|
+
"../runner/dist/handlers/computer-handlers.js"() {
|
|
39879
|
+
}
|
|
39880
|
+
});
|
|
39072
39881
|
function surfaceInputWithinCap(m) {
|
|
39073
39882
|
let upper = 2;
|
|
39074
39883
|
let primitiveOnly = true;
|
|
@@ -39100,13 +39909,15 @@ function surfaceInputWithinCap(m) {
|
|
|
39100
39909
|
var RUNNER_PROTOCOL_VERSION, MIN_COMPATIBLE_PROTOCOL_VERSION, RunnerMethod, RunnerNotification, attachmentSchema, principalSchema, attachParamsSchema, runTurnParamsSchema, abortParamsSchema, setResolverParamsSchema, modeSetActiveParamsSchema, sessionSetReasoningParamsSchema, MAX_HISTORY_PAGE_LIMIT, sessionLoadHistoryParamsSchema, providerSetActiveParamsSchema, providerSetEnabledParamsSchema, providerConfigureParamsSchema, permissionAddAllowParamsSchema, commandRunParamsSchema, MAX_TRANSCRIBE_AUDIO_B64_BYTES, MAX_SYNTHESIZE_TEXT_BYTES, MEDIA_DESCRIPTOR_MAX, transcribeParamsSchema, synthesizeParamsSchema, mcpEnableAndAttachParamsSchema, mcpDetachParamsSchema, workflowSetEnabledParamsSchema, workflowRunParamsSchema, workflowValidateDraftParamsSchema, workflowSaveParamsSchema, workflowGetRunParamsSchema, workflowResumeParamsSchema, surfaceOpenParamsSchema, MAX_SURFACE_INPUT_BYTES, surfaceInputParamsSchema, surfaceResizeParamsSchema, surfaceCloseParamsSchema;
|
|
39101
39910
|
var init_protocol2 = __esm({
|
|
39102
39911
|
"../runner/dist/protocol.js"() {
|
|
39103
|
-
RUNNER_PROTOCOL_VERSION =
|
|
39912
|
+
RUNNER_PROTOCOL_VERSION = 15;
|
|
39104
39913
|
MIN_COMPATIBLE_PROTOCOL_VERSION = 1;
|
|
39105
39914
|
RunnerMethod = {
|
|
39106
39915
|
/** client->server: handshake; returns the initial info snapshot. */
|
|
39107
39916
|
Attach: "attach",
|
|
39108
39917
|
/** client->server: re-fetch the registry snapshot. */
|
|
39109
39918
|
GetInfo: "getInfo",
|
|
39919
|
+
ComputerSnapshot: "computer.snapshot",
|
|
39920
|
+
ComputerControl: "computer.control",
|
|
39110
39921
|
/** client->server: start a turn; returns its turnId. Events stream separately. */
|
|
39111
39922
|
RunTurn: "runTurn",
|
|
39112
39923
|
/** client->server: abort an in-flight turn. */
|
|
@@ -39158,6 +39969,7 @@ var init_protocol2 = __esm({
|
|
|
39158
39969
|
WorkflowList: "workflow.list",
|
|
39159
39970
|
/** client->server: enable/disable a workflow. */
|
|
39160
39971
|
WorkflowSetEnabled: "workflow.setEnabled",
|
|
39972
|
+
WorkflowDelete: "workflow.delete",
|
|
39161
39973
|
/** client->server: run a workflow now. */
|
|
39162
39974
|
WorkflowRun: "workflow.run",
|
|
39163
39975
|
/** client->server: validate a draft workflow YAML (builder). */
|
|
@@ -39172,6 +39984,8 @@ var init_protocol2 = __esm({
|
|
|
39172
39984
|
* reported version so an older runner returns an actionable error.
|
|
39173
39985
|
*/
|
|
39174
39986
|
WorkflowResume: "workflow.resume",
|
|
39987
|
+
WorkflowApprovals: "workflow.approvals",
|
|
39988
|
+
ComputerApprovalFocus: "computer.approvalFocus",
|
|
39175
39989
|
/** client->server: list available surface kinds + availability (v8). */
|
|
39176
39990
|
SurfaceList: "surface.list",
|
|
39177
39991
|
/** client->server: open (or attach to the shared) surface instance (v8). */
|
|
@@ -39351,6 +40165,86 @@ var init_protocol2 = __esm({
|
|
|
39351
40165
|
});
|
|
39352
40166
|
}
|
|
39353
40167
|
});
|
|
40168
|
+
async function handleWorkflowDelete(ctx, raw) {
|
|
40169
|
+
const { name } = z.object({ name: z.string().min(1).max(120) }).strict().parse(raw);
|
|
40170
|
+
const view = ctx.session.workflows;
|
|
40171
|
+
if (!view?.delete)
|
|
40172
|
+
throw new Error("Workflow deletion unavailable; update the runner");
|
|
40173
|
+
await view.delete(name);
|
|
40174
|
+
}
|
|
40175
|
+
async function handleWorkflowApprovals(ctx, raw) {
|
|
40176
|
+
const command = approvalCommandSchema.parse(raw);
|
|
40177
|
+
const view = ctx.session.workflows?.approvals;
|
|
40178
|
+
if (!view)
|
|
40179
|
+
throw new Error("Workflow approvals unavailable; update the runner");
|
|
40180
|
+
if (command.action === "list")
|
|
40181
|
+
return view.list();
|
|
40182
|
+
if (command.action === "decide")
|
|
40183
|
+
return view.decide(command.id, command.choice);
|
|
40184
|
+
if (command.action === "cancel")
|
|
40185
|
+
return view.cancel(command.id);
|
|
40186
|
+
return view.revoke(command.id);
|
|
40187
|
+
}
|
|
40188
|
+
async function handleWorkflowList(ctx) {
|
|
40189
|
+
const view = ctx.session.workflows;
|
|
40190
|
+
if (!view)
|
|
40191
|
+
return [];
|
|
40192
|
+
return [...await view.list()];
|
|
40193
|
+
}
|
|
40194
|
+
async function handleWorkflowSetEnabled(ctx, raw) {
|
|
40195
|
+
const params = workflowSetEnabledParamsSchema.parse(raw);
|
|
40196
|
+
const view = ctx.session.workflows;
|
|
40197
|
+
if (!view)
|
|
40198
|
+
throw new Error("workflows plugin not loaded");
|
|
40199
|
+
await view.setEnabled(params.name, params.enabled);
|
|
40200
|
+
}
|
|
40201
|
+
async function handleWorkflowRun(ctx, raw) {
|
|
40202
|
+
const params = workflowRunParamsSchema.parse(raw);
|
|
40203
|
+
const view = ctx.session.workflows;
|
|
40204
|
+
if (!view)
|
|
40205
|
+
throw new Error("workflows plugin not loaded");
|
|
40206
|
+
return view.run(params.name);
|
|
40207
|
+
}
|
|
40208
|
+
async function handleWorkflowValidateDraft(ctx, raw) {
|
|
40209
|
+
const params = workflowValidateDraftParamsSchema.parse(raw);
|
|
40210
|
+
const view = ctx.session.workflows;
|
|
40211
|
+
if (!view?.validateDraft)
|
|
40212
|
+
throw new Error("workflows builder not supported on this runner");
|
|
40213
|
+
return view.validateDraft(params.yaml);
|
|
40214
|
+
}
|
|
40215
|
+
async function handleWorkflowSave(ctx, raw) {
|
|
40216
|
+
const params = workflowSaveParamsSchema.parse(raw);
|
|
40217
|
+
const view = ctx.session.workflows;
|
|
40218
|
+
if (!view?.save)
|
|
40219
|
+
throw new Error("workflows builder not supported on this runner");
|
|
40220
|
+
return view.save(params.yaml, params.previousName);
|
|
40221
|
+
}
|
|
40222
|
+
async function handleWorkflowGetRun(ctx, raw) {
|
|
40223
|
+
const params = workflowGetRunParamsSchema.parse(raw);
|
|
40224
|
+
const view = ctx.session.workflows;
|
|
40225
|
+
if (!view?.getRun)
|
|
40226
|
+
throw new Error("workflows builder not supported on this runner");
|
|
40227
|
+
return await view.getRun(params.name) ?? null;
|
|
40228
|
+
}
|
|
40229
|
+
async function handleWorkflowResume(ctx, raw) {
|
|
40230
|
+
const params = workflowResumeParamsSchema.parse(raw);
|
|
40231
|
+
const view = ctx.session.workflows;
|
|
40232
|
+
if (!view?.resume)
|
|
40233
|
+
throw new Error("workflow resume not supported on this runner");
|
|
40234
|
+
return view.resume(params.runId, params.reply);
|
|
40235
|
+
}
|
|
40236
|
+
var approvalCommandSchema;
|
|
40237
|
+
var init_workflow_handlers = __esm({
|
|
40238
|
+
"../runner/dist/handlers/workflow-handlers.js"() {
|
|
40239
|
+
init_protocol2();
|
|
40240
|
+
approvalCommandSchema = z.discriminatedUnion("action", [
|
|
40241
|
+
z.object({ action: z.literal("list") }).strict(),
|
|
40242
|
+
z.object({ action: z.literal("decide"), id: z.string().uuid(), choice: z.enum(["allow_once", "allow_always", "deny"]) }).strict(),
|
|
40243
|
+
z.object({ action: z.literal("revoke"), id: z.string().uuid() }).strict(),
|
|
40244
|
+
z.object({ action: z.literal("cancel"), id: z.string().uuid() }).strict()
|
|
40245
|
+
]);
|
|
40246
|
+
}
|
|
40247
|
+
});
|
|
39354
40248
|
|
|
39355
40249
|
// ../runner/dist/handlers/provider-handlers.js
|
|
39356
40250
|
async function handleProviderSetActive(ctx, raw) {
|
|
@@ -39502,61 +40396,6 @@ var init_mcp_handlers = __esm({
|
|
|
39502
40396
|
}
|
|
39503
40397
|
});
|
|
39504
40398
|
|
|
39505
|
-
// ../runner/dist/handlers/workflow-handlers.js
|
|
39506
|
-
async function handleWorkflowList(ctx) {
|
|
39507
|
-
const view = ctx.session.workflows;
|
|
39508
|
-
if (!view)
|
|
39509
|
-
return [];
|
|
39510
|
-
return [...await view.list()];
|
|
39511
|
-
}
|
|
39512
|
-
async function handleWorkflowSetEnabled(ctx, raw) {
|
|
39513
|
-
const params = workflowSetEnabledParamsSchema.parse(raw);
|
|
39514
|
-
const view = ctx.session.workflows;
|
|
39515
|
-
if (!view)
|
|
39516
|
-
throw new Error("workflows plugin not loaded");
|
|
39517
|
-
await view.setEnabled(params.name, params.enabled);
|
|
39518
|
-
}
|
|
39519
|
-
async function handleWorkflowRun(ctx, raw) {
|
|
39520
|
-
const params = workflowRunParamsSchema.parse(raw);
|
|
39521
|
-
const view = ctx.session.workflows;
|
|
39522
|
-
if (!view)
|
|
39523
|
-
throw new Error("workflows plugin not loaded");
|
|
39524
|
-
return view.run(params.name);
|
|
39525
|
-
}
|
|
39526
|
-
async function handleWorkflowValidateDraft(ctx, raw) {
|
|
39527
|
-
const params = workflowValidateDraftParamsSchema.parse(raw);
|
|
39528
|
-
const view = ctx.session.workflows;
|
|
39529
|
-
if (!view?.validateDraft)
|
|
39530
|
-
throw new Error("workflows builder not supported on this runner");
|
|
39531
|
-
return view.validateDraft(params.yaml);
|
|
39532
|
-
}
|
|
39533
|
-
async function handleWorkflowSave(ctx, raw) {
|
|
39534
|
-
const params = workflowSaveParamsSchema.parse(raw);
|
|
39535
|
-
const view = ctx.session.workflows;
|
|
39536
|
-
if (!view?.save)
|
|
39537
|
-
throw new Error("workflows builder not supported on this runner");
|
|
39538
|
-
return view.save(params.yaml, params.previousName);
|
|
39539
|
-
}
|
|
39540
|
-
async function handleWorkflowGetRun(ctx, raw) {
|
|
39541
|
-
const params = workflowGetRunParamsSchema.parse(raw);
|
|
39542
|
-
const view = ctx.session.workflows;
|
|
39543
|
-
if (!view?.getRun)
|
|
39544
|
-
throw new Error("workflows builder not supported on this runner");
|
|
39545
|
-
return await view.getRun(params.name) ?? null;
|
|
39546
|
-
}
|
|
39547
|
-
async function handleWorkflowResume(ctx, raw) {
|
|
39548
|
-
const params = workflowResumeParamsSchema.parse(raw);
|
|
39549
|
-
const view = ctx.session.workflows;
|
|
39550
|
-
if (!view?.resume)
|
|
39551
|
-
throw new Error("workflow resume not supported on this runner");
|
|
39552
|
-
return view.resume(params.runId, params.reply);
|
|
39553
|
-
}
|
|
39554
|
-
var init_workflow_handlers = __esm({
|
|
39555
|
-
"../runner/dist/handlers/workflow-handlers.js"() {
|
|
39556
|
-
init_protocol2();
|
|
39557
|
-
}
|
|
39558
|
-
});
|
|
39559
|
-
|
|
39560
40399
|
// ../runner/dist/handlers/surface-handlers.js
|
|
39561
40400
|
async function handleSurfaceList(ctx) {
|
|
39562
40401
|
return [...await ctx.session.surfaces.list()];
|
|
@@ -39658,6 +40497,8 @@ var init_server2 = __esm({
|
|
|
39658
40497
|
init_jsonrpc();
|
|
39659
40498
|
init_unix_socket();
|
|
39660
40499
|
init_socket_path();
|
|
40500
|
+
init_computer_handlers();
|
|
40501
|
+
init_workflow_handlers();
|
|
39661
40502
|
init_protocol2();
|
|
39662
40503
|
init_handlers();
|
|
39663
40504
|
CLIENT_REQUEST_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
@@ -39748,6 +40589,8 @@ var init_server2 = __esm({
|
|
|
39748
40589
|
const ctx = this.handlerCtx;
|
|
39749
40590
|
peer.handle(RunnerMethod.Attach, (raw) => this.handleAttach(client2, raw));
|
|
39750
40591
|
peer.handle(RunnerMethod.GetInfo, () => this.session.getInfo());
|
|
40592
|
+
peer.handle(RunnerMethod.ComputerSnapshot, (raw) => handleComputerSnapshot(ctx, raw));
|
|
40593
|
+
peer.handle(RunnerMethod.ComputerControl, (raw) => handleComputerControl(ctx, raw));
|
|
39751
40594
|
peer.handle(RunnerMethod.RunTurn, (raw) => this.handleRunTurn(client2, raw));
|
|
39752
40595
|
peer.handle(RunnerMethod.Abort, (raw) => this.handleAbort(client2, raw));
|
|
39753
40596
|
peer.handle(RunnerMethod.SessionReset, () => this.handleSessionReset());
|
|
@@ -39768,11 +40611,14 @@ var init_server2 = __esm({
|
|
|
39768
40611
|
peer.handle(RunnerMethod.McpDetach, (raw) => handleMcpDetach(ctx, raw));
|
|
39769
40612
|
peer.handle(RunnerMethod.WorkflowList, () => handleWorkflowList(ctx));
|
|
39770
40613
|
peer.handle(RunnerMethod.WorkflowSetEnabled, (raw) => handleWorkflowSetEnabled(ctx, raw));
|
|
40614
|
+
peer.handle(RunnerMethod.WorkflowDelete, (raw) => handleWorkflowDelete(ctx, raw));
|
|
39771
40615
|
peer.handle(RunnerMethod.WorkflowRun, (raw) => handleWorkflowRun(ctx, raw));
|
|
39772
40616
|
peer.handle(RunnerMethod.WorkflowValidateDraft, (raw) => handleWorkflowValidateDraft(ctx, raw));
|
|
39773
40617
|
peer.handle(RunnerMethod.WorkflowSave, (raw) => handleWorkflowSave(ctx, raw));
|
|
39774
40618
|
peer.handle(RunnerMethod.WorkflowGetRun, (raw) => handleWorkflowGetRun(ctx, raw));
|
|
39775
40619
|
peer.handle(RunnerMethod.WorkflowResume, (raw) => handleWorkflowResume(ctx, raw));
|
|
40620
|
+
peer.handle(RunnerMethod.WorkflowApprovals, (raw) => handleWorkflowApprovals(ctx, raw));
|
|
40621
|
+
peer.handle(RunnerMethod.ComputerApprovalFocus, (raw) => handleComputerApprovalFocus(ctx, raw));
|
|
39776
40622
|
peer.handle(RunnerMethod.SurfaceList, () => handleSurfaceList(ctx));
|
|
39777
40623
|
peer.handle(RunnerMethod.SurfaceOpen, (raw) => handleSurfaceOpen(ctx, raw));
|
|
39778
40624
|
peer.handle(RunnerMethod.SurfaceInput, (raw) => handleSurfaceInput(ctx, raw));
|
|
@@ -39976,16 +40822,16 @@ var init_server2 = __esm({
|
|
|
39976
40822
|
};
|
|
39977
40823
|
}
|
|
39978
40824
|
async resolvePermission(call, ctx) {
|
|
39979
|
-
const
|
|
39980
|
-
if (
|
|
40825
|
+
const scope2 = this.scope.getStore();
|
|
40826
|
+
if (scope2 && scope2.client.handlesPermission && !scope2.client.peer.isClosed) {
|
|
39981
40827
|
try {
|
|
39982
|
-
return await
|
|
40828
|
+
return await scope2.client.peer.request(
|
|
39983
40829
|
RunnerMethod.PermissionCheck,
|
|
39984
|
-
{ turnId:
|
|
40830
|
+
{ turnId: scope2.turnId, call, ctx },
|
|
39985
40831
|
// A client can stay socket-connected yet never answer (hung renderer
|
|
39986
40832
|
// that doesn't drop the link); the turn's signal + a bounded timeout
|
|
39987
40833
|
// make this fall through to deny instead of stalling the turn forever.
|
|
39988
|
-
{ signal: this.turnControllers.get(
|
|
40834
|
+
{ signal: this.turnControllers.get(scope2.turnId)?.controller.signal, timeoutMs: CLIENT_REQUEST_TIMEOUT_MS }
|
|
39989
40835
|
);
|
|
39990
40836
|
} catch {
|
|
39991
40837
|
return { mode: "deny", reason: "permission client unavailable" };
|
|
@@ -39994,11 +40840,11 @@ var init_server2 = __esm({
|
|
|
39994
40840
|
return this.fallbackPermission.check(call, ctx);
|
|
39995
40841
|
}
|
|
39996
40842
|
async resolveApproval(request) {
|
|
39997
|
-
const
|
|
39998
|
-
if (
|
|
39999
|
-
if (
|
|
40843
|
+
const scope2 = this.scope.getStore();
|
|
40844
|
+
if (scope2) {
|
|
40845
|
+
if (scope2.client.handlesApproval && !scope2.client.peer.isClosed) {
|
|
40000
40846
|
try {
|
|
40001
|
-
return await
|
|
40847
|
+
return await scope2.client.peer.request(RunnerMethod.ApprovalConfirm, { turnId: scope2.turnId, request }, { signal: this.turnControllers.get(scope2.turnId)?.controller.signal, timeoutMs: CLIENT_REQUEST_TIMEOUT_MS });
|
|
40002
40848
|
} catch {
|
|
40003
40849
|
return defaultApproval(request);
|
|
40004
40850
|
}
|
|
@@ -40022,6 +40868,33 @@ var init_server2 = __esm({
|
|
|
40022
40868
|
};
|
|
40023
40869
|
}
|
|
40024
40870
|
});
|
|
40871
|
+
function makeComputerControlView(ctx) {
|
|
40872
|
+
return {
|
|
40873
|
+
approvalFocus: async (input) => {
|
|
40874
|
+
ctx.requireServerProtocol(13, "Computer Use approval focus");
|
|
40875
|
+
const command = computerApprovalFocusSchema.parse(input);
|
|
40876
|
+
if (command.sessionId !== ctx.requireInfo().sessionId)
|
|
40877
|
+
throw new Error("Computer Use session mismatch");
|
|
40878
|
+
await ctx.peer.request(RunnerMethod.ComputerApprovalFocus, command);
|
|
40879
|
+
},
|
|
40880
|
+
snapshot: async () => {
|
|
40881
|
+
ctx.requireServerProtocol(12, "Reading Computer Use control");
|
|
40882
|
+
return z$1.array(computerControlSnapshotSchema).max(256).parse(await ctx.peer.request(RunnerMethod.ComputerSnapshot, {}));
|
|
40883
|
+
},
|
|
40884
|
+
control: async (input) => {
|
|
40885
|
+
ctx.requireServerProtocol(12, "Controlling Computer Use");
|
|
40886
|
+
const command = computerControlCommandSchema.parse(input);
|
|
40887
|
+
if (command.sessionId !== ctx.requireInfo().sessionId)
|
|
40888
|
+
throw new Error("Computer Use session mismatch");
|
|
40889
|
+
await ctx.peer.request(RunnerMethod.ComputerControl, command);
|
|
40890
|
+
}
|
|
40891
|
+
};
|
|
40892
|
+
}
|
|
40893
|
+
var init_computer_control = __esm({
|
|
40894
|
+
"../runner/dist/client-views/computer-control.js"() {
|
|
40895
|
+
init_protocol2();
|
|
40896
|
+
}
|
|
40897
|
+
});
|
|
40025
40898
|
function fakeProvider(name, models) {
|
|
40026
40899
|
return {
|
|
40027
40900
|
name,
|
|
@@ -40312,11 +41185,31 @@ var init_provider_admin = __esm({
|
|
|
40312
41185
|
init_protocol2();
|
|
40313
41186
|
}
|
|
40314
41187
|
});
|
|
40315
|
-
|
|
40316
|
-
// ../runner/dist/client-views/workflows.js
|
|
40317
41188
|
function makeWorkflowsView(ctx) {
|
|
40318
41189
|
const { peer, requireServerProtocol } = ctx;
|
|
40319
41190
|
return {
|
|
41191
|
+
delete: async (name) => {
|
|
41192
|
+
requireServerProtocol(15, "Workflow deletion");
|
|
41193
|
+
await peer.request(RunnerMethod.WorkflowDelete, { name });
|
|
41194
|
+
},
|
|
41195
|
+
approvals: {
|
|
41196
|
+
cancel: async (id) => {
|
|
41197
|
+
requireServerProtocol(13, "Workflow approvals");
|
|
41198
|
+
await peer.request(RunnerMethod.WorkflowApprovals, { action: "cancel", id });
|
|
41199
|
+
},
|
|
41200
|
+
list: async () => {
|
|
41201
|
+
requireServerProtocol(13, "Workflow approvals");
|
|
41202
|
+
return workflowApprovalItemsSchema.parse(await peer.request(RunnerMethod.WorkflowApprovals, { action: "list" }));
|
|
41203
|
+
},
|
|
41204
|
+
decide: async (id, choice) => {
|
|
41205
|
+
requireServerProtocol(13, "Workflow approvals");
|
|
41206
|
+
await peer.request(RunnerMethod.WorkflowApprovals, { action: "decide", id, choice });
|
|
41207
|
+
},
|
|
41208
|
+
revoke: async (id) => {
|
|
41209
|
+
requireServerProtocol(13, "Workflow approvals");
|
|
41210
|
+
await peer.request(RunnerMethod.WorkflowApprovals, { action: "revoke", id });
|
|
41211
|
+
}
|
|
41212
|
+
},
|
|
40320
41213
|
list: () => peer.request(RunnerMethod.WorkflowList),
|
|
40321
41214
|
setEnabled: async (name, enabled) => {
|
|
40322
41215
|
await peer.request(RunnerMethod.WorkflowSetEnabled, {
|
|
@@ -40545,6 +41438,7 @@ var TurnStream, MAX_COMPLETED_TURNS, RemoteSession, DEFAULT_RUNNER_PORTS, RECOVE
|
|
|
40545
41438
|
var init_remote_session = __esm({
|
|
40546
41439
|
"../runner/dist/remote-session.js"() {
|
|
40547
41440
|
init_dist2();
|
|
41441
|
+
init_computer_control();
|
|
40548
41442
|
init_jsonrpc();
|
|
40549
41443
|
init_client_views();
|
|
40550
41444
|
init_unix_socket();
|
|
@@ -40604,6 +41498,7 @@ var init_remote_session = __esm({
|
|
|
40604
41498
|
permissions;
|
|
40605
41499
|
mcpAdmin;
|
|
40606
41500
|
providerAdmin;
|
|
41501
|
+
computerControl;
|
|
40607
41502
|
workflows;
|
|
40608
41503
|
/**
|
|
40609
41504
|
* Turns that completed before their `runTurn` stream was registered. A fast
|
|
@@ -40678,17 +41573,17 @@ var init_remote_session = __esm({
|
|
|
40678
41573
|
this.mirror.clear();
|
|
40679
41574
|
});
|
|
40680
41575
|
this.peer.handle(RunnerMethod.PermissionCheck, (params) => {
|
|
40681
|
-
const { call, ctx } = params;
|
|
41576
|
+
const { call, ctx, turnId } = params;
|
|
40682
41577
|
if (!this.permissionResolver) {
|
|
40683
41578
|
return { mode: "deny", reason: "no permission resolver on client" };
|
|
40684
41579
|
}
|
|
40685
|
-
return this.permissionResolver.check(call, ctx);
|
|
41580
|
+
return this.permissionResolver.check(call, { ...ctx, turnId: String(turnId) });
|
|
40686
41581
|
});
|
|
40687
41582
|
this.peer.handle(RunnerMethod.ApprovalConfirm, (params) => {
|
|
40688
|
-
const { request } = params;
|
|
41583
|
+
const { request, turnId } = params;
|
|
40689
41584
|
if (!this.approvalResolver)
|
|
40690
41585
|
return defaultApproval2(request);
|
|
40691
|
-
return this.approvalResolver.confirm(request);
|
|
41586
|
+
return this.approvalResolver.confirm(request, { turnId: String(turnId) });
|
|
40692
41587
|
});
|
|
40693
41588
|
this.peer.onClose(() => {
|
|
40694
41589
|
for (const stream of this.turnStreams.values())
|
|
@@ -40714,6 +41609,7 @@ var init_remote_session = __esm({
|
|
|
40714
41609
|
this.permissions = makePermissionsView(view);
|
|
40715
41610
|
this.mcpAdmin = makeMcpAdminView(view);
|
|
40716
41611
|
this.providerAdmin = makeProviderAdminView(view);
|
|
41612
|
+
this.computerControl = makeComputerControlView(view);
|
|
40717
41613
|
this.workflows = makeWorkflowsView(view);
|
|
40718
41614
|
}
|
|
40719
41615
|
/**
|
|
@@ -44151,8 +45047,8 @@ function planChapter(events, live, opts) {
|
|
|
44151
45047
|
let to = -1;
|
|
44152
45048
|
for (let i = 0; i < candidates.length; i++) {
|
|
44153
45049
|
const next = candidates[i];
|
|
44154
|
-
const
|
|
44155
|
-
if (!
|
|
45050
|
+
const clean4 = events.every((e2) => !isProjected(e2) || e2.seq < candidates[0].from || e2.seq > next.to || covered(e2.seq));
|
|
45051
|
+
if (!clean4)
|
|
44156
45052
|
break;
|
|
44157
45053
|
taken = i + 1;
|
|
44158
45054
|
to = next.to;
|
|
@@ -44572,10 +45468,10 @@ var require_react_production_min = __commonJS({
|
|
|
44572
45468
|
var w = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
44573
45469
|
var x3 = /* @__PURE__ */ Symbol.for("react.memo");
|
|
44574
45470
|
var y2 = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
44575
|
-
var
|
|
45471
|
+
var z68 = Symbol.iterator;
|
|
44576
45472
|
function A(a) {
|
|
44577
45473
|
if (null === a || "object" !== typeof a) return null;
|
|
44578
|
-
a =
|
|
45474
|
+
a = z68 && a[z68] || a["@@iterator"];
|
|
44579
45475
|
return "function" === typeof a ? a : null;
|
|
44580
45476
|
}
|
|
44581
45477
|
var B2 = { isMounted: function() {
|
|
@@ -46458,7 +47354,7 @@ var require_react_development = __commonJS({
|
|
|
46458
47354
|
validatePropTypes(newElement);
|
|
46459
47355
|
return newElement;
|
|
46460
47356
|
}
|
|
46461
|
-
function startTransition(
|
|
47357
|
+
function startTransition(scope2, options) {
|
|
46462
47358
|
var prevTransition = ReactCurrentBatchConfig.transition;
|
|
46463
47359
|
ReactCurrentBatchConfig.transition = {};
|
|
46464
47360
|
var currentTransition = ReactCurrentBatchConfig.transition;
|
|
@@ -46466,7 +47362,7 @@ var require_react_development = __commonJS({
|
|
|
46466
47362
|
ReactCurrentBatchConfig.transition._updatedFibers = /* @__PURE__ */ new Set();
|
|
46467
47363
|
}
|
|
46468
47364
|
try {
|
|
46469
|
-
|
|
47365
|
+
scope2();
|
|
46470
47366
|
} finally {
|
|
46471
47367
|
ReactCurrentBatchConfig.transition = prevTransition;
|
|
46472
47368
|
{
|
|
@@ -46907,13 +47803,13 @@ __export(base_exports, {
|
|
|
46907
47803
|
exitAlternativeScreen: () => exitAlternativeScreen,
|
|
46908
47804
|
iTerm: () => iTerm,
|
|
46909
47805
|
image: () => image,
|
|
46910
|
-
link: () =>
|
|
47806
|
+
link: () => link2,
|
|
46911
47807
|
scrollDown: () => scrollDown,
|
|
46912
47808
|
scrollUp: () => scrollUp,
|
|
46913
47809
|
setCwd: () => setCwd,
|
|
46914
47810
|
synchronizedOutput: () => synchronizedOutput
|
|
46915
47811
|
});
|
|
46916
|
-
var ESC, OSC, BEL, SEP, isTerminalApp, isWindows2, isTmux, cwdFunction, wrapOsc, cursorTo, cursorMove, cursorUp, cursorDown, cursorForward, cursorBackward, cursorLeft, cursorSavePosition, cursorRestorePosition, cursorGetPosition, cursorNextLine, cursorPrevLine, cursorHide, cursorShow, eraseLines, eraseEndLine, eraseStartLine, eraseLine, eraseDown, eraseUp, eraseScreen, scrollUp, scrollDown, clearScreen, clearViewport, isOldWindows, clearTerminal, enterAlternativeScreen, exitAlternativeScreen, beginSynchronizedOutput, endSynchronizedOutput, synchronizedOutput, beep,
|
|
47812
|
+
var ESC, OSC, BEL, SEP, isTerminalApp, isWindows2, isTmux, cwdFunction, wrapOsc, cursorTo, cursorMove, cursorUp, cursorDown, cursorForward, cursorBackward, cursorLeft, cursorSavePosition, cursorRestorePosition, cursorGetPosition, cursorNextLine, cursorPrevLine, cursorHide, cursorShow, eraseLines, eraseEndLine, eraseStartLine, eraseLine, eraseDown, eraseUp, eraseScreen, scrollUp, scrollDown, clearScreen, clearViewport, isOldWindows, clearTerminal, enterAlternativeScreen, exitAlternativeScreen, beginSynchronizedOutput, endSynchronizedOutput, synchronizedOutput, beep, link2, image, iTerm, ConEmu, setCwd;
|
|
46917
47813
|
var init_base = __esm({
|
|
46918
47814
|
"../../node_modules/.pnpm/ansi-escapes@7.3.0/node_modules/ansi-escapes/base.js"() {
|
|
46919
47815
|
init_environment();
|
|
@@ -47013,7 +47909,7 @@ var init_base = __esm({
|
|
|
47013
47909
|
endSynchronizedOutput = ESC + "?2026l";
|
|
47014
47910
|
synchronizedOutput = (text2) => beginSynchronizedOutput + text2 + endSynchronizedOutput;
|
|
47015
47911
|
beep = BEL;
|
|
47016
|
-
|
|
47912
|
+
link2 = (text2, url) => {
|
|
47017
47913
|
const openLink = wrapOsc(`${OSC}8${SEP}${SEP}${url}${BEL}`);
|
|
47018
47914
|
const closeLink = wrapOsc(`${OSC}8${SEP}${SEP}${BEL}`);
|
|
47019
47915
|
return openLink + text2 + closeLink;
|
|
@@ -47382,7 +48278,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
47382
48278
|
h.noExitRuntime || true;
|
|
47383
48279
|
"object" != typeof WebAssembly && x3("no native wasm support detected");
|
|
47384
48280
|
var fa, ha = false;
|
|
47385
|
-
function
|
|
48281
|
+
function z68(a, b, c) {
|
|
47386
48282
|
c = b + c;
|
|
47387
48283
|
for (var d2 = ""; !(b >= c); ) {
|
|
47388
48284
|
var e2 = a[b++];
|
|
@@ -48032,7 +48928,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
48032
48928
|
return b;
|
|
48033
48929
|
}, Jb = {
|
|
48034
48930
|
l: function(a, b, c, d2) {
|
|
48035
|
-
x3("Assertion failed: " + (a ?
|
|
48931
|
+
x3("Assertion failed: " + (a ? z68(A, a) : "") + ", at: " + [b ? b ? z68(A, b) : "" : "unknown filename", c, d2 ? d2 ? z68(A, d2) : "" : "unknown function"]);
|
|
48036
48932
|
},
|
|
48037
48933
|
q: function(a, b, c) {
|
|
48038
48934
|
a = N3(a);
|
|
@@ -48285,7 +49181,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
48285
49181
|
if (c) for (var g = f, k2 = 0; k2 <= e2; ++k2) {
|
|
48286
49182
|
var m = f + k2;
|
|
48287
49183
|
if (k2 == e2 || 0 == A[m]) {
|
|
48288
|
-
g = g ?
|
|
49184
|
+
g = g ? z68(A, g, m - g) : "";
|
|
48289
49185
|
if (void 0 === l) var l = g;
|
|
48290
49186
|
else l += String.fromCharCode(0), l += g;
|
|
48291
49187
|
g = m + 1;
|
|
@@ -48482,7 +49378,7 @@ var init_yoga_wasm_base64_esm = __esm({
|
|
|
48482
49378
|
b += 8;
|
|
48483
49379
|
for (var m = 0; m < k2; m++) {
|
|
48484
49380
|
var l = A[g + m], n = Fb[a];
|
|
48485
|
-
0 === l || 10 === l ? ((1 === a ? ea : v)(
|
|
49381
|
+
0 === l || 10 === l ? ((1 === a ? ea : v)(z68(n, 0)), n.length = 0) : n.push(l);
|
|
48486
49382
|
}
|
|
48487
49383
|
e2 += k2;
|
|
48488
49384
|
}
|
|
@@ -48970,7 +49866,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
48970
49866
|
var u = 1;
|
|
48971
49867
|
var v = null;
|
|
48972
49868
|
var y2 = 3;
|
|
48973
|
-
var
|
|
49869
|
+
var z68 = false;
|
|
48974
49870
|
var A = false;
|
|
48975
49871
|
var B2 = false;
|
|
48976
49872
|
var D2 = "function" === typeof setTimeout ? setTimeout : null;
|
|
@@ -48997,7 +49893,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
48997
49893
|
function J3(a, b) {
|
|
48998
49894
|
A = false;
|
|
48999
49895
|
B2 && (B2 = false, E(L2), L2 = -1);
|
|
49000
|
-
|
|
49896
|
+
z68 = true;
|
|
49001
49897
|
var c = y2;
|
|
49002
49898
|
try {
|
|
49003
49899
|
G2(b);
|
|
@@ -49021,7 +49917,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
49021
49917
|
}
|
|
49022
49918
|
return w;
|
|
49023
49919
|
} finally {
|
|
49024
|
-
v = null, y2 = c,
|
|
49920
|
+
v = null, y2 = c, z68 = false;
|
|
49025
49921
|
}
|
|
49026
49922
|
}
|
|
49027
49923
|
var N3 = false;
|
|
@@ -49078,7 +49974,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
49078
49974
|
a.callback = null;
|
|
49079
49975
|
};
|
|
49080
49976
|
exports.unstable_continueExecution = function() {
|
|
49081
|
-
A ||
|
|
49977
|
+
A || z68 || (A = true, I2(J3));
|
|
49082
49978
|
};
|
|
49083
49979
|
exports.unstable_forceFrameRate = function(a) {
|
|
49084
49980
|
0 > a || 125 < a ? console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported") : P2 = 0 < a ? Math.floor(1e3 / a) : 5;
|
|
@@ -49151,7 +50047,7 @@ var require_scheduler_production_min = __commonJS({
|
|
|
49151
50047
|
}
|
|
49152
50048
|
e2 = c + e2;
|
|
49153
50049
|
a = { id: u++, callback: b, priorityLevel: a, startTime: c, expirationTime: e2, sortIndex: -1 };
|
|
49154
|
-
c > d2 ? (a.sortIndex = c, f(t, a), null === h(r) && a === h(t) && (B2 ? (E(L2), L2 = -1) : B2 = true, K3(H3, c - d2))) : (a.sortIndex = e2, f(r, a), A ||
|
|
50050
|
+
c > d2 ? (a.sortIndex = c, f(t, a), null === h(r) && a === h(t) && (B2 ? (E(L2), L2 = -1) : B2 = true, K3(H3, c - d2))) : (a.sortIndex = e2, f(r, a), A || z68 || (A = true, I2(J3)));
|
|
49155
50051
|
return a;
|
|
49156
50052
|
};
|
|
49157
50053
|
exports.unstable_shouldYield = M3;
|
|
@@ -49425,9 +50321,9 @@ var require_scheduler_development = __commonJS({
|
|
|
49425
50321
|
var currentTime = exports.unstable_now();
|
|
49426
50322
|
var startTime2;
|
|
49427
50323
|
if (typeof options === "object" && options !== null) {
|
|
49428
|
-
var
|
|
49429
|
-
if (typeof
|
|
49430
|
-
startTime2 = currentTime +
|
|
50324
|
+
var delay4 = options.delay;
|
|
50325
|
+
if (typeof delay4 === "number" && delay4 > 0) {
|
|
50326
|
+
startTime2 = currentTime + delay4;
|
|
49431
50327
|
} else {
|
|
49432
50328
|
startTime2 = currentTime;
|
|
49433
50329
|
}
|
|
@@ -49908,7 +50804,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
49908
50804
|
gc[hc] = a.current;
|
|
49909
50805
|
a.current = b;
|
|
49910
50806
|
}
|
|
49911
|
-
var jc = {}, x3 = ic(jc),
|
|
50807
|
+
var jc = {}, x3 = ic(jc), z68 = ic(false), kc = jc;
|
|
49912
50808
|
function mc(a, b) {
|
|
49913
50809
|
var c = a.type.contextTypes;
|
|
49914
50810
|
if (!c) return jc;
|
|
@@ -49924,13 +50820,13 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
49924
50820
|
return null !== a && void 0 !== a;
|
|
49925
50821
|
}
|
|
49926
50822
|
function nc() {
|
|
49927
|
-
q3(
|
|
50823
|
+
q3(z68);
|
|
49928
50824
|
q3(x3);
|
|
49929
50825
|
}
|
|
49930
50826
|
function oc(a, b, c) {
|
|
49931
50827
|
if (x3.current !== jc) throw Error(n(168));
|
|
49932
50828
|
v(x3, b);
|
|
49933
|
-
v(
|
|
50829
|
+
v(z68, c);
|
|
49934
50830
|
}
|
|
49935
50831
|
function pc(a, b, c) {
|
|
49936
50832
|
var d2 = a.stateNode;
|
|
@@ -49944,14 +50840,14 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
49944
50840
|
a = (a = a.stateNode) && a.__reactInternalMemoizedMergedChildContext || jc;
|
|
49945
50841
|
kc = x3.current;
|
|
49946
50842
|
v(x3, a);
|
|
49947
|
-
v(
|
|
50843
|
+
v(z68, z68.current);
|
|
49948
50844
|
return true;
|
|
49949
50845
|
}
|
|
49950
50846
|
function rc(a, b, c) {
|
|
49951
50847
|
var d2 = a.stateNode;
|
|
49952
50848
|
if (!d2) throw Error(n(169));
|
|
49953
|
-
c ? (a = pc(a, b, kc), d2.__reactInternalMemoizedMergedChildContext = a, q3(
|
|
49954
|
-
v(
|
|
50849
|
+
c ? (a = pc(a, b, kc), d2.__reactInternalMemoizedMergedChildContext = a, q3(z68), q3(x3), v(x3, a)) : q3(z68);
|
|
50850
|
+
v(z68, c);
|
|
49955
50851
|
}
|
|
49956
50852
|
var tc = Math.clz32 ? Math.clz32 : sc, uc = Math.log, vc = Math.LN2;
|
|
49957
50853
|
function sc(a) {
|
|
@@ -51549,7 +52445,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
51549
52445
|
g.state = p;
|
|
51550
52446
|
ke2(b, d2, g, e2);
|
|
51551
52447
|
k2 = b.memoizedState;
|
|
51552
|
-
h !== d2 || p !== k2 ||
|
|
52448
|
+
h !== d2 || p !== k2 || z68.current || de2 ? ("function" === typeof m && (yf(b, c, m, d2), k2 = b.memoizedState), (h = de2 || Af(b, c, h, d2, p, k2, l)) ? (r || "function" !== typeof g.UNSAFE_componentWillMount && "function" !== typeof g.componentWillMount || ("function" === typeof g.componentWillMount && g.componentWillMount(), "function" === typeof g.UNSAFE_componentWillMount && g.UNSAFE_componentWillMount()), "function" === typeof g.componentDidMount && (b.flags |= 4194308)) : ("function" === typeof g.componentDidMount && (b.flags |= 4194308), b.memoizedProps = d2, b.memoizedState = k2), g.props = d2, g.state = k2, g.context = l, d2 = h) : ("function" === typeof g.componentDidMount && (b.flags |= 4194308), d2 = false);
|
|
51553
52449
|
} else {
|
|
51554
52450
|
g = b.stateNode;
|
|
51555
52451
|
fe2(a, b);
|
|
@@ -51567,7 +52463,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
51567
52463
|
g.state = p;
|
|
51568
52464
|
ke2(b, d2, g, e2);
|
|
51569
52465
|
var w = b.memoizedState;
|
|
51570
|
-
h !== r || p !== w ||
|
|
52466
|
+
h !== r || p !== w || z68.current || de2 ? ("function" === typeof B2 && (yf(b, c, B2, d2), w = b.memoizedState), (l = de2 || Af(b, c, l, d2, p, w, k2) || false) ? (m || "function" !== typeof g.UNSAFE_componentWillUpdate && "function" !== typeof g.componentWillUpdate || ("function" === typeof g.componentWillUpdate && g.componentWillUpdate(d2, w, k2), "function" === typeof g.UNSAFE_componentWillUpdate && g.UNSAFE_componentWillUpdate(d2, w, k2)), "function" === typeof g.componentDidUpdate && (b.flags |= 4), "function" === typeof g.getSnapshotBeforeUpdate && (b.flags |= 1024)) : ("function" !== typeof g.componentDidUpdate || h === a.memoizedProps && p === a.memoizedState || (b.flags |= 4), "function" !== typeof g.getSnapshotBeforeUpdate || h === a.memoizedProps && p === a.memoizedState || (b.flags |= 1024), b.memoizedProps = d2, b.memoizedState = w), g.props = d2, g.state = w, g.context = k2, d2 = l) : ("function" !== typeof g.componentDidUpdate || h === a.memoizedProps && p === a.memoizedState || (b.flags |= 4), "function" !== typeof g.getSnapshotBeforeUpdate || h === a.memoizedProps && p === a.memoizedState || (b.flags |= 1024), d2 = false);
|
|
51571
52467
|
}
|
|
51572
52468
|
return dg(a, b, c, d2, f, e2);
|
|
51573
52469
|
}
|
|
@@ -52036,7 +52932,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
52036
52932
|
case 3:
|
|
52037
52933
|
c = b.stateNode;
|
|
52038
52934
|
te();
|
|
52039
|
-
q3(
|
|
52935
|
+
q3(z68);
|
|
52040
52936
|
q3(x3);
|
|
52041
52937
|
ye2();
|
|
52042
52938
|
c.pendingContext && (c.context = c.pendingContext, c.pendingContext = null);
|
|
@@ -52179,7 +53075,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
52179
53075
|
case 1:
|
|
52180
53076
|
return A(b.type) && nc(), a = b.flags, a & 65536 ? (b.flags = a & -65537 | 128, b) : null;
|
|
52181
53077
|
case 3:
|
|
52182
|
-
return te(), q3(
|
|
53078
|
+
return te(), q3(z68), q3(x3), ye2(), a = b.flags, 0 !== (a & 65536) && 0 === (a & 128) ? (b.flags = a & -65537 | 128, b) : null;
|
|
52183
53079
|
case 5:
|
|
52184
53080
|
return ve2(b), null;
|
|
52185
53081
|
case 13:
|
|
@@ -53234,7 +54130,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
53234
54130
|
break;
|
|
53235
54131
|
case 3:
|
|
53236
54132
|
te();
|
|
53237
|
-
q3(
|
|
54133
|
+
q3(z68);
|
|
53238
54134
|
q3(x3);
|
|
53239
54135
|
ye2();
|
|
53240
54136
|
break;
|
|
@@ -53711,7 +54607,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
53711
54607
|
}
|
|
53712
54608
|
var ai;
|
|
53713
54609
|
ai = function(a, b, c) {
|
|
53714
|
-
if (null !== a) if (a.memoizedProps !== b.pendingProps ||
|
|
54610
|
+
if (null !== a) if (a.memoizedProps !== b.pendingProps || z68.current) G2 = true;
|
|
53715
54611
|
else {
|
|
53716
54612
|
if (0 === (a.lanes & c) && 0 === (b.flags & 128)) return G2 = false, sg(a, b, c);
|
|
53717
54613
|
G2 = 0 !== (a.flags & 131072) ? true : false;
|
|
@@ -53820,7 +54716,7 @@ var require_react_reconciler_production_min = __commonJS({
|
|
|
53820
54716
|
g = e2.value;
|
|
53821
54717
|
Vd(b, d2, g);
|
|
53822
54718
|
if (null !== f) if (Vc(f.value, g)) {
|
|
53823
|
-
if (f.children === e2.children && !
|
|
54719
|
+
if (f.children === e2.children && !z68.current) {
|
|
53824
54720
|
b = Tf(a, b, c);
|
|
53825
54721
|
break a;
|
|
53826
54722
|
}
|
|
@@ -76551,10 +77447,10 @@ var init_inline2 = __esm({
|
|
|
76551
77447
|
LinkToken = ({ label: label3, url }) => {
|
|
76552
77448
|
const visibleLabel = terminalSafeText(label3, 512);
|
|
76553
77449
|
const enabled = terminalHyperlinksEnabled();
|
|
76554
|
-
const
|
|
77450
|
+
const link3 = terminalHyperlinkText(visibleLabel, url, enabled);
|
|
76555
77451
|
const hint = formatLinkHint(url, visibleLabel.length, void 0, enabled);
|
|
76556
77452
|
const linkedHint = hint ? terminalHyperlinkText(hint, url, enabled) : "";
|
|
76557
|
-
return (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [(0, import_jsx_runtime9.jsx)(Text, { underline: true, color: "blue", children:
|
|
77453
|
+
return (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [(0, import_jsx_runtime9.jsx)(Text, { underline: true, color: "blue", children: link3 }), (0, import_jsx_runtime9.jsx)(Text, { dimColor: true, children: linkedHint })] });
|
|
76558
77454
|
};
|
|
76559
77455
|
OSC_LINK = "\x1B]8;;";
|
|
76560
77456
|
OSC_END = "\x1B\\";
|
|
@@ -77347,9 +78243,9 @@ function stepFold(s, e2) {
|
|
|
77347
78243
|
}
|
|
77348
78244
|
if (e2.type === "tool_result") {
|
|
77349
78245
|
if (s.suppressedCallIds.has(e2.callId)) {
|
|
77350
|
-
const
|
|
77351
|
-
if (
|
|
77352
|
-
|
|
78246
|
+
const scope2 = s.suppressedSkillScopes.get(e2.callId);
|
|
78247
|
+
if (scope2)
|
|
78248
|
+
scope2.loading = false;
|
|
77353
78249
|
s.suppressedSkillScopes.delete(e2.callId);
|
|
77354
78250
|
return;
|
|
77355
78251
|
}
|
|
@@ -77361,9 +78257,9 @@ function stepFold(s, e2) {
|
|
|
77361
78257
|
}
|
|
77362
78258
|
if (e2.type === "tool_call_denied") {
|
|
77363
78259
|
if (s.suppressedCallIds.has(e2.callId)) {
|
|
77364
|
-
const
|
|
77365
|
-
if (
|
|
77366
|
-
|
|
78260
|
+
const scope2 = s.suppressedSkillScopes.get(e2.callId);
|
|
78261
|
+
if (scope2)
|
|
78262
|
+
scope2.loading = false;
|
|
77367
78263
|
s.suppressedSkillScopes.delete(e2.callId);
|
|
77368
78264
|
return;
|
|
77369
78265
|
}
|
|
@@ -77810,21 +78706,21 @@ var init_SubagentScopeView = __esm({
|
|
|
77810
78706
|
init_density();
|
|
77811
78707
|
init_dist27();
|
|
77812
78708
|
init_motion();
|
|
77813
|
-
SubagentScopeView = ({ scope }) => {
|
|
78709
|
+
SubagentScopeView = ({ scope: scope2 }) => {
|
|
77814
78710
|
const [now, setNow] = (0, import_react39.useState)(() => Date.now());
|
|
77815
|
-
const running =
|
|
78711
|
+
const running = scope2.completedAtMs == null && scope2.error == null;
|
|
77816
78712
|
(0, import_react39.useEffect)(() => {
|
|
77817
78713
|
if (!running || !MOTION_ENABLED)
|
|
77818
78714
|
return;
|
|
77819
78715
|
const t = setInterval(() => setNow(Date.now()), 1e3);
|
|
77820
78716
|
return () => clearInterval(t);
|
|
77821
78717
|
}, [running]);
|
|
77822
|
-
const endMs =
|
|
77823
|
-
const elapsed = formatElapsed(endMs -
|
|
77824
|
-
const toolPart = `${
|
|
77825
|
-
const dotColor =
|
|
77826
|
-
const state =
|
|
77827
|
-
return (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "column", marginTop: blockGap(), children: [(0, import_jsx_runtime18.jsxs)(Box_default, { children: [(0, import_jsx_runtime18.jsxs)(Text, { color: dotColor, children: [Glyphs.filled, " "] }), (0, import_jsx_runtime18.jsx)(Text, { bold: true, children: `agent ` }), (0, import_jsx_runtime18.jsx)(Text, { children:
|
|
78718
|
+
const endMs = scope2.completedAtMs ?? now;
|
|
78719
|
+
const elapsed = formatElapsed(endMs - scope2.startedAtMs);
|
|
78720
|
+
const toolPart = `${scope2.toolCallCount} tool call${scope2.toolCallCount === 1 ? "" : "s"}`;
|
|
78721
|
+
const dotColor = scope2.error ? Colors.danger : running ? Colors.busy : DotColors.subagent;
|
|
78722
|
+
const state = scope2.error ? "failed" : running ? "running" : "done";
|
|
78723
|
+
return (0, import_jsx_runtime18.jsxs)(Box_default, { flexDirection: "column", marginTop: blockGap(), children: [(0, import_jsx_runtime18.jsxs)(Box_default, { children: [(0, import_jsx_runtime18.jsxs)(Text, { color: dotColor, children: [Glyphs.filled, " "] }), (0, import_jsx_runtime18.jsx)(Text, { bold: true, children: `agent ` }), (0, import_jsx_runtime18.jsx)(Text, { children: scope2.label }), (0, import_jsx_runtime18.jsx)(Text, { dimColor: true, children: ` ${state} ${elapsed} \xB7 ${toolPart}` })] }), scope2.error ? (0, import_jsx_runtime18.jsxs)(Box_default, { marginLeft: 2, children: [(0, import_jsx_runtime18.jsx)(Text, { dimColor: true, children: "\u2514 " }), (0, import_jsx_runtime18.jsx)(Text, { color: Colors.danger, children: truncate4(scope2.error, 100) })] }) : scope2.finalPreview && !running ? (0, import_jsx_runtime18.jsx)(Box_default, { marginLeft: 2, children: (0, import_jsx_runtime18.jsx)(Text, { dimColor: true, children: `\u2514 ${truncate4(scope2.finalPreview, 100)}` }) }) : null] });
|
|
77828
78724
|
};
|
|
77829
78725
|
}
|
|
77830
78726
|
});
|
|
@@ -77883,24 +78779,24 @@ var init_CollabScopeView = __esm({
|
|
|
77883
78779
|
MAX_AGENTS = 8;
|
|
77884
78780
|
MAX_TASKS = 6;
|
|
77885
78781
|
MAX_MSGS = 6;
|
|
77886
|
-
CollabScopeView = ({ scope }) => {
|
|
78782
|
+
CollabScopeView = ({ scope: scope2 }) => {
|
|
77887
78783
|
const [now, setNow] = (0, import_react41.useState)(() => Date.now());
|
|
77888
|
-
const running =
|
|
78784
|
+
const running = scope2.completedAtMs == null;
|
|
77889
78785
|
(0, import_react41.useEffect)(() => {
|
|
77890
78786
|
if (!running || !MOTION_ENABLED)
|
|
77891
78787
|
return;
|
|
77892
78788
|
const t = setInterval(() => setNow(Date.now()), 1e3);
|
|
77893
78789
|
return () => clearInterval(t);
|
|
77894
78790
|
}, [running]);
|
|
77895
|
-
const elapsed = formatElapsed((
|
|
77896
|
-
const done =
|
|
77897
|
-
const state = running ?
|
|
77898
|
-
const headColor =
|
|
77899
|
-
return (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "column", marginTop: blockGap(), children: [(0, import_jsx_runtime20.jsxs)(Box_default, { children: [(0, import_jsx_runtime20.jsxs)(Text, { color: headColor, children: [Glyphs.filled, " "] }), (0, import_jsx_runtime20.jsx)(Text, { bold: true, children: "collab " }), (0, import_jsx_runtime20.jsx)(Text, { children: truncate4(
|
|
78791
|
+
const elapsed = formatElapsed((scope2.completedAtMs ?? now) - scope2.startedAtMs);
|
|
78792
|
+
const done = scope2.agents.filter((a) => a.status === "done").length;
|
|
78793
|
+
const state = running ? scope2.control?.paused ? "paused" : "running" : scope2.conflicts.length > 0 ? "done \xB7 conflicts" : "done";
|
|
78794
|
+
const headColor = scope2.conflicts.length > 0 ? Colors.danger : Colors.busy;
|
|
78795
|
+
return (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "column", marginTop: blockGap(), children: [(0, import_jsx_runtime20.jsxs)(Box_default, { children: [(0, import_jsx_runtime20.jsxs)(Text, { color: headColor, children: [Glyphs.filled, " "] }), (0, import_jsx_runtime20.jsx)(Text, { bold: true, children: "collab " }), (0, import_jsx_runtime20.jsx)(Text, { children: truncate4(scope2.task, 50) }), (0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: ` ${state} ${elapsed} \xB7 ${done}/${scope2.agents.length} done` })] }), scope2.fallbackReason ? (0, import_jsx_runtime20.jsx)(Box_default, { marginLeft: 2, children: (0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: `! ${truncate4(scope2.fallbackReason, 90)}` }) }) : null, (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "column", marginLeft: 2, children: [scope2.agents.slice(0, MAX_AGENTS).map((a) => {
|
|
77900
78796
|
const glyph = a.status === "done" ? "\u2713" : a.status === "working" ? "\u25CF" : a.status === "crashed" ? "\u2717" : "\u25CB";
|
|
77901
78797
|
const statusProps = a.status === "working" ? { color: Colors.busy } : a.status === "crashed" ? { color: Colors.danger } : { dimColor: true };
|
|
77902
78798
|
return (0, import_jsx_runtime20.jsxs)(Box_default, { children: [(0, import_jsx_runtime20.jsxs)(Text, { ...statusProps, children: [glyph, " "] }), (0, import_jsx_runtime20.jsx)(Text, { children: a.name }), (0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: ` ${a.role} \xB7 ${a.status}` })] }, a.id);
|
|
77903
|
-
}),
|
|
78799
|
+
}), scope2.agents.length > MAX_AGENTS ? (0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: ` +${scope2.agents.length - MAX_AGENTS} more` }) : null] }), scope2.tasks.length > 0 ? (0, import_jsx_runtime20.jsxs)(Box_default, { flexDirection: "column", marginLeft: 2, children: [(0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: `board (${scope2.tasks.filter((t) => t.status === "done").length}/${scope2.tasks.length})` }), scope2.tasks.slice(0, MAX_TASKS).map((t) => (0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: ` [${t.status}] ${truncate4(t.title, 40)}${t.owner ? ` @${t.owner}` : ""}` }, t.id))] }) : null, scope2.contracts.length > 0 ? (0, import_jsx_runtime20.jsx)(Box_default, { marginLeft: 2, children: (0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: `contracts: ${truncate4(scope2.contracts.map((c) => c.title).join(", "), 80)}` }) }) : null, scope2.messages.length > 0 ? (0, import_jsx_runtime20.jsx)(Box_default, { flexDirection: "column", marginLeft: 2, children: scope2.messages.slice(-MAX_MSGS).map((m) => (0, import_jsx_runtime20.jsx)(Text, { dimColor: true, children: ` ${m.from} \u2192 ${m.to}: ${truncate4(m.body, 70)}` }, m.id)) }) : null] });
|
|
77904
78800
|
};
|
|
77905
78801
|
}
|
|
77906
78802
|
});
|
|
@@ -77959,8 +78855,8 @@ var init_ShimmerText = __esm({
|
|
|
77959
78855
|
});
|
|
77960
78856
|
|
|
77961
78857
|
// ../plugin-cli/dist/components/chat/BlockLine.js
|
|
77962
|
-
function skillActivityPresentation(
|
|
77963
|
-
const name = truncate4(
|
|
78858
|
+
function skillActivityPresentation(scope2, childToolCount = countToolCalls(scope2.children), active2 = scope2.loading) {
|
|
78859
|
+
const name = truncate4(scope2.skillEvent.name, NAME_DISPLAY_MAX);
|
|
77964
78860
|
const meta = childToolCount > 0 ? `${childToolCount} tool${childToolCount === 1 ? "" : "s"}` : null;
|
|
77965
78861
|
return { label: name, meta, active: active2 };
|
|
77966
78862
|
}
|
|
@@ -78044,16 +78940,16 @@ var init_BlockLine = __esm({
|
|
|
78044
78940
|
return blocksEquivalent(prev.block, next.block);
|
|
78045
78941
|
}
|
|
78046
78942
|
);
|
|
78047
|
-
SkillScopeView = ({ scope, expandToolOutputs, renderVersion }) => {
|
|
78048
|
-
const childToolCount = countToolCalls(
|
|
78049
|
-
const runningTools =
|
|
78050
|
-
const presentation = skillActivityPresentation(
|
|
78943
|
+
SkillScopeView = ({ scope: scope2, expandToolOutputs, renderVersion }) => {
|
|
78944
|
+
const childToolCount = countToolCalls(scope2.children);
|
|
78945
|
+
const runningTools = scope2.children.some(hasRunningTool);
|
|
78946
|
+
const presentation = skillActivityPresentation(scope2, childToolCount, scope2.loading || !scope2.closed || runningTools);
|
|
78051
78947
|
const hasDetails = childToolCount > 0;
|
|
78052
|
-
const showChildren = hasDetails && (!
|
|
78053
|
-
const failed =
|
|
78054
|
-
const dotState =
|
|
78055
|
-
const activityText = `${
|
|
78056
|
-
return (0, import_jsx_runtime22.jsxs)(Box_default, { flexDirection: "column", marginTop: blockGap(), children: [(0, import_jsx_runtime22.jsxs)(Box_default, { children: [(0, import_jsx_runtime22.jsx)(ActivityDot, { state: dotState }), (0, import_jsx_runtime22.jsx)(Text, { children: " " }), (0, import_jsx_runtime22.jsx)(ShimmerText, { text: activityText, active: presentation.active }), presentation.meta ? (0, import_jsx_runtime22.jsx)(Text, { dimColor: true, children: ` \xB7 ${presentation.meta}` }) : null,
|
|
78948
|
+
const showChildren = hasDetails && (!scope2.closed || runningTools || expandToolOutputs);
|
|
78949
|
+
const failed = scope2.children.some(hasFailedTool);
|
|
78950
|
+
const dotState = scope2.loading ? "neutral" : presentation.active ? "active" : failed ? "error" : "success";
|
|
78951
|
+
const activityText = `${scope2.loading ? "Loading" : presentation.active ? "Using" : failed ? "Failed" : "Used"} ${presentation.label}`;
|
|
78952
|
+
return (0, import_jsx_runtime22.jsxs)(Box_default, { flexDirection: "column", marginTop: blockGap(), children: [(0, import_jsx_runtime22.jsxs)(Box_default, { children: [(0, import_jsx_runtime22.jsx)(ActivityDot, { state: dotState }), (0, import_jsx_runtime22.jsx)(Text, { children: " " }), (0, import_jsx_runtime22.jsx)(ShimmerText, { text: activityText, active: presentation.active }), presentation.meta ? (0, import_jsx_runtime22.jsx)(Text, { dimColor: true, children: ` \xB7 ${presentation.meta}` }) : null, scope2.closed && hasDetails ? (0, import_jsx_runtime22.jsx)(Text, { dimColor: true, children: ` \xB7 Ctrl+O ${showChildren ? "collapse" : "details"}` }) : null] }), showChildren ? (0, import_jsx_runtime22.jsx)(Box_default, { flexDirection: "column", marginLeft: 2, children: scope2.children.map((c) => (0, import_jsx_runtime22.jsx)(BlockLine, { block: c, expandToolOutputs, renderVersion, nested: true }, c.id)) }) : null] });
|
|
78057
78953
|
};
|
|
78058
78954
|
}
|
|
78059
78955
|
});
|
|
@@ -81386,8 +82282,8 @@ function orderByScope(skills) {
|
|
|
81386
82282
|
buckets.set(s.scope, list);
|
|
81387
82283
|
}
|
|
81388
82284
|
const out = [];
|
|
81389
|
-
for (const
|
|
81390
|
-
const list = buckets.get(
|
|
82285
|
+
for (const scope2 of ORDER) {
|
|
82286
|
+
const list = buckets.get(scope2);
|
|
81391
82287
|
if (!list)
|
|
81392
82288
|
continue;
|
|
81393
82289
|
list.sort((a, b) => a.frontmatter.name.localeCompare(b.frontmatter.name));
|
|
@@ -81779,13 +82675,13 @@ var init_UsagePanel = __esm({
|
|
|
81779
82675
|
const series = import_react58.default.useMemo(() => perCallPrompt(events), [events]);
|
|
81780
82676
|
const [lifetime, setLifetime] = import_react58.default.useState(null);
|
|
81781
82677
|
import_react58.default.useEffect(() => {
|
|
81782
|
-
let
|
|
82678
|
+
let alive2 = true;
|
|
81783
82679
|
void loadUsageStats().then((f) => {
|
|
81784
|
-
if (
|
|
82680
|
+
if (alive2)
|
|
81785
82681
|
setLifetime(f);
|
|
81786
82682
|
});
|
|
81787
82683
|
return () => {
|
|
81788
|
-
|
|
82684
|
+
alive2 = false;
|
|
81789
82685
|
};
|
|
81790
82686
|
}, []);
|
|
81791
82687
|
const liveByModel = import_react58.default.useMemo(() => summarizeTokensByModel(events), [events]);
|
|
@@ -84336,6 +85232,10 @@ var init_remote = __esm({
|
|
|
84336
85232
|
// `workflows.validateDraft`, `workflows.setEnabled`) is host-only — a paired
|
|
84337
85233
|
// phone must not rewrite or re-enable the host's workflows.
|
|
84338
85234
|
"workflows.list",
|
|
85235
|
+
"workflows.approvals",
|
|
85236
|
+
"workflows.decideApproval",
|
|
85237
|
+
"workflows.revokeApproval",
|
|
85238
|
+
"workflows.cancelApprovalRun",
|
|
84339
85239
|
"workflows.run",
|
|
84340
85240
|
"workflows.getRun",
|
|
84341
85241
|
// Answer a paused workflow's awaitInput question. This is RESPOND-only — like
|
|
@@ -84485,6 +85385,8 @@ var init_validation = __esm({
|
|
|
84485
85385
|
// with an oversized string. All currently-valid payloads (a short turn id, an
|
|
84486
85386
|
// optional workspace slug, an optional desk id, or no arg at all) still pass.
|
|
84487
85387
|
"session.info": z.object({ workspaceId: optionalWorkspace }).optional(),
|
|
85388
|
+
"computer.snapshot": z.object({ workspaceId: z.string().min(1).max(160) }).strict(),
|
|
85389
|
+
"computer.control": computerControlCommandSchema.extend({ workspaceId: z.string().min(1).max(160) }).strict(),
|
|
84488
85390
|
"session.abortTurn": z.object({
|
|
84489
85391
|
workspaceId: optionalWorkspace,
|
|
84490
85392
|
turnId: z.string().min(1).max(256)
|
|
@@ -84559,6 +85461,7 @@ var init_validation = __esm({
|
|
|
84559
85461
|
}),
|
|
84560
85462
|
"workflows.run": z.object({ name: workflowName }),
|
|
84561
85463
|
"workflows.setEnabled": z.object({ name: workflowName, enabled: z.boolean() }),
|
|
85464
|
+
"workflows.delete": z.object({ name: workflowName }).strict(),
|
|
84562
85465
|
// Builder commands. validateDraft/save take full YAML — bound the size so a
|
|
84563
85466
|
// hostile renderer can't OOM the host; save writes to disk so it's
|
|
84564
85467
|
// filesystem-touching and gets a boundary check like the other writers.
|
|
@@ -84587,6 +85490,10 @@ var init_validation = __esm({
|
|
|
84587
85490
|
runId: z.string().min(1).max(120),
|
|
84588
85491
|
reply: z.string().min(1).max(1e5)
|
|
84589
85492
|
}),
|
|
85493
|
+
"workflows.approvals": z.object({ workspaceId: z.string().min(1) }).strict(),
|
|
85494
|
+
"workflows.decideApproval": z.object({ workspaceId: z.string().min(1), id: z.string().uuid(), choice: z.enum(["allow_once", "allow_always", "deny"]) }).strict(),
|
|
85495
|
+
"workflows.revokeApproval": z.object({ workspaceId: z.string().min(1), id: z.string().uuid() }).strict(),
|
|
85496
|
+
"workflows.cancelApprovalRun": z.object({ workspaceId: z.string().min(1), id: z.string().uuid() }).strict(),
|
|
84590
85497
|
// Security-sensitive: this bypasses the approval sheet, so validate it at
|
|
84591
85498
|
// the boundary like the other dangerous commands.
|
|
84592
85499
|
"session.setAutoApprove": z.object({ workspaceId: optionalWorkspace, enabled: z.boolean() }),
|
|
@@ -85405,6 +86312,18 @@ var init_single_session_host = __esm({
|
|
|
85405
86312
|
/** Register the `IpcCommands` subset the mobile client drives. */
|
|
85406
86313
|
register() {
|
|
85407
86314
|
this.bus.handle("connection.snapshotAll", async () => this.connectionSnapshots());
|
|
86315
|
+
const workflowApprovals = (workspaceId) => {
|
|
86316
|
+
if (workspaceId !== this.workspaceId)
|
|
86317
|
+
throw new IpcError("not-connected", "Workflow approval workspace is not served by this host");
|
|
86318
|
+
const view = this.session.workflows;
|
|
86319
|
+
if (!view?.approvals)
|
|
86320
|
+
throw new IpcError("not-connected", "Workflow approvals require an updated runner");
|
|
86321
|
+
return view.approvals;
|
|
86322
|
+
};
|
|
86323
|
+
this.bus.handle("workflows.approvals", async ({ workspaceId }) => workflowApprovals(workspaceId).list());
|
|
86324
|
+
this.bus.handle("workflows.decideApproval", async ({ workspaceId, id, choice }) => workflowApprovals(workspaceId).decide(id, choice));
|
|
86325
|
+
this.bus.handle("workflows.revokeApproval", async ({ workspaceId, id }) => workflowApprovals(workspaceId).revoke(id));
|
|
86326
|
+
this.bus.handle("workflows.cancelApprovalRun", async ({ workspaceId, id }) => workflowApprovals(workspaceId).cancel(id));
|
|
85408
86327
|
this.bus.handle("connection.activeWorkspace", async () => this.activeWorkspaceId());
|
|
85409
86328
|
this.bus.handle("connection.retry", async () => {
|
|
85410
86329
|
});
|
|
@@ -91330,30 +92249,30 @@ function stringifyValue2(value2) {
|
|
|
91330
92249
|
return value2;
|
|
91331
92250
|
return JSON.stringify(value2);
|
|
91332
92251
|
}
|
|
91333
|
-
function resolveRef(ref,
|
|
92252
|
+
function resolveRef(ref, scope2) {
|
|
91334
92253
|
const parts = ref.split(".").map((p) => p.trim());
|
|
91335
92254
|
const [head2, ...rest] = parts;
|
|
91336
92255
|
switch (head2) {
|
|
91337
92256
|
case "trigger":
|
|
91338
|
-
return
|
|
92257
|
+
return scope2.trigger ?? "";
|
|
91339
92258
|
case "now":
|
|
91340
|
-
return
|
|
92259
|
+
return scope2.now ?? "";
|
|
91341
92260
|
case "steps": {
|
|
91342
92261
|
const id = rest[0];
|
|
91343
92262
|
if (!id)
|
|
91344
92263
|
return void 0;
|
|
91345
|
-
const out =
|
|
92264
|
+
const out = scope2.steps[id]?.output;
|
|
91346
92265
|
return out ?? "";
|
|
91347
92266
|
}
|
|
91348
92267
|
case "inputs":
|
|
91349
|
-
return rest[0] ?
|
|
92268
|
+
return rest[0] ? scope2.inputs[rest[0]] : void 0;
|
|
91350
92269
|
case "vars":
|
|
91351
|
-
return rest[0] ?
|
|
92270
|
+
return rest[0] ? scope2.vars?.[rest[0]] : void 0;
|
|
91352
92271
|
default:
|
|
91353
92272
|
return void 0;
|
|
91354
92273
|
}
|
|
91355
92274
|
}
|
|
91356
|
-
function renderTemplate(text2,
|
|
92275
|
+
function renderTemplate(text2, scope2, opts = {}) {
|
|
91357
92276
|
const output = [];
|
|
91358
92277
|
let cursor = 0;
|
|
91359
92278
|
while (cursor < text2.length) {
|
|
@@ -91371,7 +92290,7 @@ function renderTemplate(text2, scope, opts = {}) {
|
|
|
91371
92290
|
continue;
|
|
91372
92291
|
}
|
|
91373
92292
|
output.push(text2.slice(cursor, open2));
|
|
91374
|
-
const value2 = resolveRef(ref.trim(),
|
|
92293
|
+
const value2 = resolveRef(ref.trim(), scope2);
|
|
91375
92294
|
if (value2 === void 0) {
|
|
91376
92295
|
const logger = opts.logger;
|
|
91377
92296
|
if (logger?.warn)
|
|
@@ -91384,15 +92303,15 @@ function renderTemplate(text2, scope, opts = {}) {
|
|
|
91384
92303
|
output.push(text2.slice(cursor));
|
|
91385
92304
|
return output.join("");
|
|
91386
92305
|
}
|
|
91387
|
-
function renderArgs(args,
|
|
92306
|
+
function renderArgs(args, scope2, opts = {}) {
|
|
91388
92307
|
if (typeof args === "string")
|
|
91389
|
-
return renderTemplate(args,
|
|
92308
|
+
return renderTemplate(args, scope2, opts);
|
|
91390
92309
|
if (Array.isArray(args))
|
|
91391
|
-
return args.map((v) => renderArgs(v,
|
|
92310
|
+
return args.map((v) => renderArgs(v, scope2, opts));
|
|
91392
92311
|
if (args && typeof args === "object") {
|
|
91393
92312
|
const out = {};
|
|
91394
92313
|
for (const [k2, v] of Object.entries(args)) {
|
|
91395
|
-
out[k2] = renderArgs(v,
|
|
92314
|
+
out[k2] = renderArgs(v, scope2, opts);
|
|
91396
92315
|
}
|
|
91397
92316
|
return out;
|
|
91398
92317
|
}
|
|
@@ -91434,8 +92353,8 @@ function parseCondition(expr) {
|
|
|
91434
92353
|
const orGroups = splitTop(trimmed, "or").map((group) => splitTop(group, "and").map(parseAtom));
|
|
91435
92354
|
return { orGroups };
|
|
91436
92355
|
}
|
|
91437
|
-
function evalAtom(atom,
|
|
91438
|
-
const value2 = renderTemplate(atom.lhs.includes("{{") ? atom.lhs : `{{ ${atom.lhs} }}`,
|
|
92356
|
+
function evalAtom(atom, scope2) {
|
|
92357
|
+
const value2 = renderTemplate(atom.lhs.includes("{{") ? atom.lhs : `{{ ${atom.lhs} }}`, scope2).trim();
|
|
91439
92358
|
switch (atom.kind) {
|
|
91440
92359
|
case "empty":
|
|
91441
92360
|
return value2 === "";
|
|
@@ -91449,9 +92368,9 @@ function evalAtom(atom, scope) {
|
|
|
91449
92368
|
return value2 !== atom.literal;
|
|
91450
92369
|
}
|
|
91451
92370
|
}
|
|
91452
|
-
function evalCondition(expr,
|
|
92371
|
+
function evalCondition(expr, scope2) {
|
|
91453
92372
|
const { orGroups } = parseCondition(expr);
|
|
91454
|
-
return orGroups.some((group) => group.every((atom) => evalAtom(atom,
|
|
92373
|
+
return orGroups.some((group) => group.every((atom) => evalAtom(atom, scope2)));
|
|
91455
92374
|
}
|
|
91456
92375
|
function validateCondition(expr) {
|
|
91457
92376
|
try {
|
|
@@ -91986,7 +92905,7 @@ async function discoverWorkflows(opts = {}) {
|
|
|
91986
92905
|
}
|
|
91987
92906
|
return [...byName.values()];
|
|
91988
92907
|
}
|
|
91989
|
-
async function loadDir2(dir,
|
|
92908
|
+
async function loadDir2(dir, scope2, logger) {
|
|
91990
92909
|
let entries;
|
|
91991
92910
|
try {
|
|
91992
92911
|
entries = await promises.readdir(dir, { withFileTypes: true });
|
|
@@ -91996,7 +92915,7 @@ async function loadDir2(dir, scope, logger) {
|
|
|
91996
92915
|
const out = [];
|
|
91997
92916
|
for (const entry of entries) {
|
|
91998
92917
|
if (entry.isDirectory()) {
|
|
91999
|
-
out.push(...await loadDir2(path3.join(dir, entry.name),
|
|
92918
|
+
out.push(...await loadDir2(path3.join(dir, entry.name), scope2, logger));
|
|
92000
92919
|
continue;
|
|
92001
92920
|
}
|
|
92002
92921
|
if (!entry.isFile() || !/\.ya?ml$/i.test(entry.name))
|
|
@@ -92032,7 +92951,7 @@ async function loadDir2(dir, scope, logger) {
|
|
|
92032
92951
|
logger.warn("workflow: invalid file, skipping", { path: full, errors: result.errors });
|
|
92033
92952
|
continue;
|
|
92034
92953
|
}
|
|
92035
|
-
out.push({ workflow: result.workflow, path: full, scope });
|
|
92954
|
+
out.push({ workflow: result.workflow, path: full, scope: scope2 });
|
|
92036
92955
|
}
|
|
92037
92956
|
return out;
|
|
92038
92957
|
}
|
|
@@ -92154,17 +93073,17 @@ var init_store4 = __esm({
|
|
|
92154
93073
|
return this.byName.get(name)?.workflow;
|
|
92155
93074
|
}
|
|
92156
93075
|
/** Write a new workflow file and register it. Rejects duplicate names. */
|
|
92157
|
-
async create(workflow,
|
|
93076
|
+
async create(workflow, scope2) {
|
|
92158
93077
|
return this.mutex.run(async () => {
|
|
92159
93078
|
await this.ensureLoadedUnlocked();
|
|
92160
93079
|
if (this.byName.has(workflow.name)) {
|
|
92161
93080
|
throw new Error(`workflow "${workflow.name}" already exists \u2014 use update instead`);
|
|
92162
93081
|
}
|
|
92163
|
-
const dir =
|
|
93082
|
+
const dir = scope2 === "project" ? this.projectDir() : this.userDir();
|
|
92164
93083
|
await promises.mkdir(dir, { recursive: true });
|
|
92165
93084
|
const file = await uniqueFilename(dir, workflow.name);
|
|
92166
93085
|
await writeFileAtomic(file, serializeWorkflow(workflow));
|
|
92167
|
-
const entry = { workflow, path: file, scope };
|
|
93086
|
+
const entry = { workflow, path: file, scope: scope2 };
|
|
92168
93087
|
this.byName.set(workflow.name, entry);
|
|
92169
93088
|
return entry;
|
|
92170
93089
|
});
|
|
@@ -92196,12 +93115,12 @@ var init_store4 = __esm({
|
|
|
92196
93115
|
this.byName.set(workflow.name, entry2);
|
|
92197
93116
|
return entry2;
|
|
92198
93117
|
}
|
|
92199
|
-
const
|
|
92200
|
-
const dir =
|
|
93118
|
+
const scope2 = renamed?.scope === "project" ? "project" : "user";
|
|
93119
|
+
const dir = scope2 === "project" ? this.projectDir() : this.userDir();
|
|
92201
93120
|
await promises.mkdir(dir, { recursive: true });
|
|
92202
93121
|
const file = await uniqueFilename(dir, workflow.name);
|
|
92203
93122
|
await writeFileAtomic(file, serializeWorkflow(workflow));
|
|
92204
|
-
const entry = { workflow, path: file, scope };
|
|
93123
|
+
const entry = { workflow, path: file, scope: scope2 };
|
|
92205
93124
|
this.byName.set(workflow.name, entry);
|
|
92206
93125
|
return entry;
|
|
92207
93126
|
}
|
|
@@ -92562,14 +93481,14 @@ var init_state_serde = __esm({
|
|
|
92562
93481
|
init_context();
|
|
92563
93482
|
}
|
|
92564
93483
|
});
|
|
92565
|
-
async function runStep(step,
|
|
93484
|
+
async function runStep(step, scope2, ctx) {
|
|
92566
93485
|
const attempts = step.onError === "retry" ? 1 + Math.max(0, step.retries) : 1;
|
|
92567
93486
|
let lastError = "";
|
|
92568
93487
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
92569
93488
|
if (ctx.deps.signal.aborted)
|
|
92570
93489
|
return { ok: false, output: "", error: "aborted" };
|
|
92571
93490
|
try {
|
|
92572
|
-
return await runStepOnce(step,
|
|
93491
|
+
return await runStepOnce(step, scope2, ctx);
|
|
92573
93492
|
} catch (err) {
|
|
92574
93493
|
lastError = err instanceof Error ? err.message : String(err);
|
|
92575
93494
|
const logger = ctx.deps.logger;
|
|
@@ -92583,28 +93502,28 @@ async function runStep(step, scope, ctx) {
|
|
|
92583
93502
|
}
|
|
92584
93503
|
return { ok: false, output: "", error: lastError };
|
|
92585
93504
|
}
|
|
92586
|
-
async function runStepOnce(step,
|
|
93505
|
+
async function runStepOnce(step, scope2, ctx) {
|
|
92587
93506
|
const { deps } = ctx;
|
|
92588
93507
|
const opts = deps.logger ? { logger: deps.logger } : {};
|
|
92589
93508
|
if (step.loop != null) {
|
|
92590
93509
|
return runLoopStep(step, ctx, opts);
|
|
92591
93510
|
}
|
|
92592
93511
|
if (step.bridge != null || step.condition != null || step.switch != null) {
|
|
92593
|
-
return runLogicStep(step,
|
|
93512
|
+
return runLogicStep(step, scope2, ctx, opts);
|
|
92594
93513
|
}
|
|
92595
93514
|
if (step.echo != null) {
|
|
92596
|
-
return { ok: true, output: renderTemplate(step.echo,
|
|
93515
|
+
return { ok: true, output: renderTemplate(step.echo, scope2, opts) };
|
|
92597
93516
|
}
|
|
92598
93517
|
if (step.tool) {
|
|
92599
|
-
const args = renderArgs(step.args ?? {},
|
|
93518
|
+
const args = renderArgs(step.args ?? {}, scope2, opts);
|
|
92600
93519
|
const result = await deps.tools.execute(step.tool, args, deps.signal);
|
|
92601
93520
|
const output = typeof result === "string" ? result : JSON.stringify(result ?? "");
|
|
92602
93521
|
return { ok: true, output };
|
|
92603
93522
|
}
|
|
92604
93523
|
if (step.workflow) {
|
|
92605
|
-
return runNestedWorkflow(step,
|
|
93524
|
+
return runNestedWorkflow(step, scope2, ctx, opts);
|
|
92606
93525
|
}
|
|
92607
|
-
const spec = buildSubagentSpecWithDeps(step,
|
|
93526
|
+
const spec = buildSubagentSpecWithDeps(step, scope2, deps, opts);
|
|
92608
93527
|
if (step.awaitInput) {
|
|
92609
93528
|
const child2 = await deps.spawner.spawn({ ...spec, retainSession: true });
|
|
92610
93529
|
if (child2.error)
|
|
@@ -92621,7 +93540,7 @@ async function runStepOnce(step, scope, ctx) {
|
|
|
92621
93540
|
throw new Error(child.error.message);
|
|
92622
93541
|
return { ok: true, output: child.text };
|
|
92623
93542
|
}
|
|
92624
|
-
async function runNestedWorkflow(step,
|
|
93543
|
+
async function runNestedWorkflow(step, scope2, ctx, opts) {
|
|
92625
93544
|
const { deps } = ctx;
|
|
92626
93545
|
assertDefined(step.workflow, "runNestedWorkflow is only invoked for workflow steps");
|
|
92627
93546
|
const nested = deps.lookup.workflow(step.workflow);
|
|
@@ -92631,7 +93550,7 @@ async function runNestedWorkflow(step, scope, ctx, opts) {
|
|
|
92631
93550
|
if (depth > MAX_NESTING_DEPTH) {
|
|
92632
93551
|
throw new Error(`nested workflow depth exceeded ${MAX_NESTING_DEPTH}`);
|
|
92633
93552
|
}
|
|
92634
|
-
const nestedInputs = renderArgs(step.args ?? {},
|
|
93553
|
+
const nestedInputs = renderArgs(step.args ?? {}, scope2, opts);
|
|
92635
93554
|
const result = await ctx.runNested(nested, {
|
|
92636
93555
|
...deps,
|
|
92637
93556
|
inputs: nestedInputs,
|
|
@@ -92650,11 +93569,11 @@ async function runNestedWorkflow(step, scope, ctx, opts) {
|
|
|
92650
93569
|
throw new Error(result.error ?? `nested workflow "${step.workflow}" failed`);
|
|
92651
93570
|
return { ok: true, output: result.output };
|
|
92652
93571
|
}
|
|
92653
|
-
function buildUpstreamBlock(step,
|
|
93572
|
+
function buildUpstreamBlock(step, scope2) {
|
|
92654
93573
|
if (step.needs.length === 0)
|
|
92655
93574
|
return "";
|
|
92656
93575
|
const parts = step.needs.map((id) => {
|
|
92657
|
-
const entry =
|
|
93576
|
+
const entry = scope2.steps?.[id];
|
|
92658
93577
|
return `### ${id}
|
|
92659
93578
|
${entry?.output ?? ""}`;
|
|
92660
93579
|
});
|
|
@@ -92663,13 +93582,13 @@ ${entry?.output ?? ""}`;
|
|
|
92663
93582
|
## Upstream
|
|
92664
93583
|
${parts.join("\n\n")}`;
|
|
92665
93584
|
}
|
|
92666
|
-
async function runLogicStep(step,
|
|
93585
|
+
async function runLogicStep(step, scope2, ctx, opts) {
|
|
92667
93586
|
const instruction = step.bridge ?? step.condition ?? step.switch ?? "";
|
|
92668
93587
|
const format = wantsPlainResponse(step) ? "plain" : "json";
|
|
92669
93588
|
if ((step.condition != null || step.switch != null) && format === "plain") {
|
|
92670
93589
|
return { ok: false, output: "", error: "condition/switch steps require JSON responses" };
|
|
92671
93590
|
}
|
|
92672
|
-
const userPrompt = renderTemplate(instruction,
|
|
93591
|
+
const userPrompt = renderTemplate(instruction, scope2, opts) + buildUpstreamBlock(step, scope2);
|
|
92673
93592
|
const spec = {
|
|
92674
93593
|
prompt: userPrompt,
|
|
92675
93594
|
...format === "json" ? { systemPrompt: logicSystemPrompt() } : {},
|
|
@@ -92799,8 +93718,8 @@ ${lastBodyOutput}` : "")
|
|
|
92799
93718
|
};
|
|
92800
93719
|
}
|
|
92801
93720
|
async function evaluateLoopCondition(step, condition, ctx, opts) {
|
|
92802
|
-
const
|
|
92803
|
-
const userPrompt = renderTemplate(condition,
|
|
93721
|
+
const scope2 = buildScope(ctx, new Date(ctx.now()).toISOString());
|
|
93722
|
+
const userPrompt = renderTemplate(condition, scope2, opts) + `
|
|
92804
93723
|
|
|
92805
93724
|
This is the loop's EXIT condition. Evaluate whether it is now met. Reply with {"branch":"then"} if the condition IS met (stop the loop and continue to the next step), or {"branch":"else"} if it is NOT yet met (run another iteration).`;
|
|
92806
93725
|
const spec = {
|
|
@@ -92827,9 +93746,9 @@ This is the loop's EXIT condition. Evaluate whether it is now met. Reply with {"
|
|
|
92827
93746
|
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
92828
93747
|
}
|
|
92829
93748
|
}
|
|
92830
|
-
function buildSubagentSpecWithDeps(step,
|
|
93749
|
+
function buildSubagentSpecWithDeps(step, scope2, deps, opts) {
|
|
92831
93750
|
const label3 = step.label ?? step.id;
|
|
92832
|
-
const renderedInput = step.input ? renderTemplate(step.input,
|
|
93751
|
+
const renderedInput = step.input ? renderTemplate(step.input, scope2, opts) : "";
|
|
92833
93752
|
if (step.skill) {
|
|
92834
93753
|
const skill = deps.lookup.skill(step.skill);
|
|
92835
93754
|
if (!skill)
|
|
@@ -92845,7 +93764,7 @@ function buildSubagentSpecWithDeps(step, scope, deps, opts) {
|
|
|
92845
93764
|
spec.allowedTools = allowed;
|
|
92846
93765
|
return spec;
|
|
92847
93766
|
}
|
|
92848
|
-
return { prompt: renderTemplate(step.prompt ?? "",
|
|
93767
|
+
return { prompt: renderTemplate(step.prompt ?? "", scope2, opts), label: label3 };
|
|
92849
93768
|
}
|
|
92850
93769
|
var init_steps = __esm({
|
|
92851
93770
|
"../plugin-workflows/dist/executor/steps.js"() {
|
|
@@ -92885,10 +93804,10 @@ async function runExecutorLoop(ctx, resumed = false) {
|
|
|
92885
93804
|
continue;
|
|
92886
93805
|
if (step.when == null)
|
|
92887
93806
|
continue;
|
|
92888
|
-
const
|
|
93807
|
+
const scope3 = buildScope(ctx, new Date(ctx.now()).toISOString());
|
|
92889
93808
|
let keep;
|
|
92890
93809
|
try {
|
|
92891
|
-
keep = evalCondition(step.when,
|
|
93810
|
+
keep = evalCondition(step.when, scope3);
|
|
92892
93811
|
} catch (err) {
|
|
92893
93812
|
st3.status = "failed";
|
|
92894
93813
|
st3.error = `when: ${err instanceof Error ? err.message : String(err)}`;
|
|
@@ -92929,9 +93848,9 @@ async function runExecutorLoop(ctx, resumed = false) {
|
|
|
92929
93848
|
break;
|
|
92930
93849
|
}
|
|
92931
93850
|
const wave = ready.slice(0, Math.max(1, workflow.concurrency));
|
|
92932
|
-
const
|
|
93851
|
+
const scope2 = buildScope(ctx, new Date(ctx.now()).toISOString());
|
|
92933
93852
|
for (const step of wave) {
|
|
92934
|
-
if (aborted)
|
|
93853
|
+
if (aborted || deps.signal.aborted)
|
|
92935
93854
|
break;
|
|
92936
93855
|
const st3 = ctx.states.get(step.id);
|
|
92937
93856
|
assertDefined(st3, "runExecutor initializes a state for every step");
|
|
@@ -92940,8 +93859,14 @@ async function runExecutorLoop(ctx, resumed = false) {
|
|
|
92940
93859
|
id: step.id,
|
|
92941
93860
|
label: step.label ?? step.id
|
|
92942
93861
|
});
|
|
92943
|
-
const outcome = await runStep(step,
|
|
93862
|
+
const outcome = await runStep(step, scope2, ctx);
|
|
92944
93863
|
st3.endedAt = ctx.now();
|
|
93864
|
+
if (deps.signal.aborted) {
|
|
93865
|
+
st3.status = "cancelled";
|
|
93866
|
+
st3.output = outcome.output;
|
|
93867
|
+
await deps.emit?.("workflow_step_cancelled", { id: step.id });
|
|
93868
|
+
break;
|
|
93869
|
+
}
|
|
92945
93870
|
if (outcome.paused) {
|
|
92946
93871
|
const interactionAgentId = outcome.interactionAgentId;
|
|
92947
93872
|
assertDefined(interactionAgentId, "a paused outcome always carries interactionAgentId");
|
|
@@ -93007,6 +93932,10 @@ async function runExecutorLoop(ctx, resumed = false) {
|
|
|
93007
93932
|
}
|
|
93008
93933
|
const ok = !aborted;
|
|
93009
93934
|
const output = sinkOutput(workflow, ctx.states);
|
|
93935
|
+
if (deps.signal.aborted) {
|
|
93936
|
+
await deps.emit?.("workflow_cancelled", { name: workflow.name });
|
|
93937
|
+
return buildRunResult(ctx, "cancelled", false, { output });
|
|
93938
|
+
}
|
|
93010
93939
|
if (ok) {
|
|
93011
93940
|
await deps.emit?.("workflow_completed", {
|
|
93012
93941
|
name: workflow.name,
|
|
@@ -93102,11 +94031,13 @@ async function resumeWorkflowRunInner(runId, userMessage, deps, store) {
|
|
|
93102
94031
|
const finalizePrompt = `Operator reply:
|
|
93103
94032
|
${userMessage.trim()}${FINALIZE_REPLY_SUFFIX}`;
|
|
93104
94033
|
try {
|
|
94034
|
+
deps.signal.throwIfAborted();
|
|
93105
94035
|
const child = await deps.spawner.continue({
|
|
93106
94036
|
childSessionId: checkpoint.interactionAgentId,
|
|
93107
94037
|
prompt: finalizePrompt,
|
|
93108
94038
|
label: step.label ?? step.id
|
|
93109
94039
|
});
|
|
94040
|
+
deps.signal.throwIfAborted();
|
|
93110
94041
|
if (child.error)
|
|
93111
94042
|
throw new Error(child.error.message);
|
|
93112
94043
|
st3.status = "completed";
|
|
@@ -93117,6 +94048,14 @@ ${userMessage.trim()}${FINALIZE_REPLY_SUFFIX}`;
|
|
|
93117
94048
|
preview: child.text.slice(0, 280)
|
|
93118
94049
|
});
|
|
93119
94050
|
} catch (err) {
|
|
94051
|
+
if (deps.signal.aborted) {
|
|
94052
|
+
st3.status = "cancelled";
|
|
94053
|
+
st3.endedAt = ctx.now();
|
|
94054
|
+
await store.remove(runId);
|
|
94055
|
+
await deps.emit?.("workflow_step_cancelled", { id: step.id });
|
|
94056
|
+
await deps.emit?.("workflow_cancelled", { runId, name: checkpoint.workflow.name });
|
|
94057
|
+
return buildRunResult(ctx, "cancelled", false, { runId });
|
|
94058
|
+
}
|
|
93120
94059
|
const message = err instanceof Error ? err.message : String(err);
|
|
93121
94060
|
st3.status = "failed";
|
|
93122
94061
|
st3.error = message;
|
|
@@ -93205,6 +94144,7 @@ async function writeRunRecord2(workflow, result, startedAt, executorName, deps,
|
|
|
93205
94144
|
startedAt,
|
|
93206
94145
|
trigger: deps.trigger ?? "manual",
|
|
93207
94146
|
ok: result.ok,
|
|
94147
|
+
status: result.status,
|
|
93208
94148
|
...result.error ? { error: result.error } : {}
|
|
93209
94149
|
}),
|
|
93210
94150
|
...result.steps.map((s) => JSON.stringify({ kind: "step", ...s })),
|
|
@@ -93461,7 +94401,7 @@ function buildRunDeps(deps, ctx, inputs, trigger) {
|
|
|
93461
94401
|
}) : void 0;
|
|
93462
94402
|
return {
|
|
93463
94403
|
spawner: ctx.subagents,
|
|
93464
|
-
tools: deps.tools,
|
|
94404
|
+
tools: deps.toolsForTurn ? deps.toolsForTurn(ctx) : deps.tools,
|
|
93465
94405
|
lookup: {
|
|
93466
94406
|
skill: (n) => deps.skills.byName(n),
|
|
93467
94407
|
workflow: (n) => deps.store.lookup(n)
|
|
@@ -93515,7 +94455,7 @@ function createTool(deps) {
|
|
|
93515
94455
|
timeMs: 12e4
|
|
93516
94456
|
}
|
|
93517
94457
|
},
|
|
93518
|
-
handler: async ({ intent, scope }, ctx) => {
|
|
94458
|
+
handler: async ({ intent, scope: scope2 }, ctx) => {
|
|
93519
94459
|
const provider = deps.provider?.();
|
|
93520
94460
|
if (!provider) {
|
|
93521
94461
|
throw new MoxxyError({ code: "PROVIDER_NOT_CONFIGURED", message: "workflow_create: no active provider to draft with." });
|
|
@@ -93532,8 +94472,8 @@ function createTool(deps) {
|
|
|
93532
94472
|
message: drafted.truncated ? "workflow_create: the draft hit the output-token limit before the YAML was complete. Try a simpler intent, or split the workflow into smaller ones." : `workflow_create: the model did not produce a valid workflow (${drafted.parse.errors.join("; ")}). Try a more specific intent.`
|
|
93533
94473
|
});
|
|
93534
94474
|
}
|
|
93535
|
-
const created = await deps.store.create(drafted.parse.workflow,
|
|
93536
|
-
emitChange(deps, ctx, "workflow_created", { name: created.workflow.name, scope });
|
|
94475
|
+
const created = await deps.store.create(drafted.parse.workflow, scope2);
|
|
94476
|
+
emitChange(deps, ctx, "workflow_created", { name: created.workflow.name, scope: scope2 });
|
|
93537
94477
|
await deps.onChanged?.();
|
|
93538
94478
|
return { name: created.workflow.name, scope: created.scope, path: created.path, steps: created.workflow.steps.length };
|
|
93539
94479
|
}
|
|
@@ -93611,7 +94551,7 @@ function deleteTool(deps) {
|
|
|
93611
94551
|
if (!res.ok)
|
|
93612
94552
|
throw new MoxxyError({ code: "TOOL_ERROR", message: `workflow_delete: ${res.reason}.` });
|
|
93613
94553
|
emitChange(deps, ctx, "workflow_deleted", { name });
|
|
93614
|
-
await deps.onChanged?.();
|
|
94554
|
+
await deps.onChanged?.(name);
|
|
93615
94555
|
return { name, deleted: true };
|
|
93616
94556
|
}
|
|
93617
94557
|
});
|
|
@@ -93651,11 +94591,15 @@ function runTool(deps) {
|
|
|
93651
94591
|
message: "workflow_run: no subagent spawner \u2014 must be invoked from a run-turn loop."
|
|
93652
94592
|
});
|
|
93653
94593
|
}
|
|
93654
|
-
const
|
|
93655
|
-
const
|
|
93656
|
-
|
|
93657
|
-
|
|
93658
|
-
|
|
94594
|
+
const spawner = ctx.subagents;
|
|
94595
|
+
const execute = (signal = ctx.signal) => {
|
|
94596
|
+
const runDeps = buildRunDeps(deps, { sessionId: ctx.sessionId, turnId: ctx.turnId, signal, subagents: deps.subagentsForTurn ? deps.subagentsForTurn(ctx.turnId, signal) : spawner }, inputs, "manual");
|
|
94597
|
+
return runWorkflow(entry.workflow, runDeps, {
|
|
94598
|
+
executor: deps.getActiveExecutor(),
|
|
94599
|
+
...deps.runRecordDir !== void 0 ? { recordDir: deps.runRecordDir } : {}
|
|
94600
|
+
});
|
|
94601
|
+
};
|
|
94602
|
+
const result = await (deps.runScoped ? deps.runScoped(name, ctx, execute, entry.workflow) : execute());
|
|
93659
94603
|
return {
|
|
93660
94604
|
ok: result.ok,
|
|
93661
94605
|
output: result.output,
|
|
@@ -93848,7 +94792,7 @@ async function runCmd2(deps, name) {
|
|
|
93848
94792
|
].filter((l) => l !== "");
|
|
93849
94793
|
return { kind: "text", text: lines.join("\n") };
|
|
93850
94794
|
}
|
|
93851
|
-
const head2 = result.ok ? `\u2713 workflow "${name}" completed` : `\u2717 workflow "${name}" failed${result.error ? `: ${result.error}` : ""}`;
|
|
94795
|
+
const head2 = result.status === "cancelled" ? `\u25A0 workflow "${name}" stopped` : result.ok ? `\u2713 workflow "${name}" completed` : `\u2717 workflow "${name}" failed${result.error ? `: ${result.error}` : ""}`;
|
|
93852
94796
|
return { kind: "text", text: `${head2}
|
|
93853
94797
|
${steps}
|
|
93854
94798
|
|
|
@@ -93924,11 +94868,11 @@ async function rmCmd(deps, name) {
|
|
|
93924
94868
|
const res = await deps.store.delete(name);
|
|
93925
94869
|
if (!res.ok)
|
|
93926
94870
|
return { kind: "error", message: `cannot delete "${name}": ${res.reason}.` };
|
|
93927
|
-
await deps.onChanged?.();
|
|
94871
|
+
await deps.onChanged?.(name);
|
|
93928
94872
|
return { kind: "text", text: `deleted workflow "${name}".` };
|
|
93929
94873
|
}
|
|
93930
94874
|
function statusMark(status) {
|
|
93931
|
-
return status === "completed" ? "\u2713" : status === "skipped" ? "\u2013" : status === "failed" ? "\u2717" : "\xB7";
|
|
94875
|
+
return status === "cancelled" ? "\u25A0" : status === "completed" ? "\u2713" : status === "skipped" ? "\u2013" : status === "failed" ? "\u2717" : "\xB7";
|
|
93932
94876
|
}
|
|
93933
94877
|
async function readLastRun(dir, name) {
|
|
93934
94878
|
if (!dir)
|
|
@@ -93948,7 +94892,7 @@ async function readLastRun(dir, name) {
|
|
|
93948
94892
|
if (run2?.workflow !== name)
|
|
93949
94893
|
continue;
|
|
93950
94894
|
const steps = lines.filter((l) => l.kind === "step");
|
|
93951
|
-
const head2 = `${run2.ok ? "\u2713" : "\u2717"} ${new Date(Number(run2.startedAt ?? 0)).toISOString()} (${String(run2.trigger ?? "?")})`;
|
|
94895
|
+
const head2 = `${run2.status === "cancelled" ? "\u25A0 stopped" : run2.ok ? "\u2713" : "\u2717"} ${new Date(Number(run2.startedAt ?? 0)).toISOString()} (${String(run2.trigger ?? "?")})`;
|
|
93952
94896
|
const stepLines = steps.map((s) => ` ${statusMark(String(s.status))} ${String(s.id)}`).join("\n");
|
|
93953
94897
|
return `${head2}
|
|
93954
94898
|
${stepLines}`;
|
|
@@ -94022,6 +94966,9 @@ function buildWorkflowsPlugin(opts) {
|
|
|
94022
94966
|
store: opts.store,
|
|
94023
94967
|
skills: opts.skills,
|
|
94024
94968
|
tools: opts.tools,
|
|
94969
|
+
...opts.toolsForTurn ? { toolsForTurn: opts.toolsForTurn } : {},
|
|
94970
|
+
...opts.runScoped ? { runScoped: opts.runScoped } : {},
|
|
94971
|
+
...opts.subagentsForTurn ? { subagentsForTurn: opts.subagentsForTurn } : {},
|
|
94025
94972
|
getActiveExecutor: opts.getActiveExecutor,
|
|
94026
94973
|
...opts.appendEvent ? { appendEvent: opts.appendEvent } : {},
|
|
94027
94974
|
...opts.logger ? { logger: opts.logger } : {},
|
|
@@ -94093,7 +95040,13 @@ function buildWorkflowRunner(args) {
|
|
|
94093
95040
|
async function runNow(input) {
|
|
94094
95041
|
const entry = await store.get(input.name);
|
|
94095
95042
|
if (!entry) {
|
|
94096
|
-
return {
|
|
95043
|
+
return {
|
|
95044
|
+
ok: false,
|
|
95045
|
+
status: "failed",
|
|
95046
|
+
steps: [],
|
|
95047
|
+
output: "",
|
|
95048
|
+
error: `no workflow named "${input.name}"`
|
|
95049
|
+
};
|
|
94097
95050
|
}
|
|
94098
95051
|
if (inFlight.has(input.name)) {
|
|
94099
95052
|
return {
|
|
@@ -94106,41 +95059,49 @@ function buildWorkflowRunner(args) {
|
|
|
94106
95059
|
}
|
|
94107
95060
|
inFlight.add(input.name);
|
|
94108
95061
|
try {
|
|
95062
|
+
const parentSignal = input.signal ? AbortSignal.any([session.signal, input.signal]) : session.signal;
|
|
95063
|
+
parentSignal.throwIfAborted();
|
|
94109
95064
|
const turnId = session.startTurn().turnId;
|
|
94110
|
-
const
|
|
94111
|
-
|
|
94112
|
-
|
|
94113
|
-
|
|
94114
|
-
|
|
94115
|
-
|
|
94116
|
-
|
|
94117
|
-
|
|
94118
|
-
|
|
94119
|
-
|
|
94120
|
-
|
|
94121
|
-
|
|
94122
|
-
|
|
94123
|
-
|
|
95065
|
+
const execute = (signal = parentSignal) => {
|
|
95066
|
+
const spawner = createSubagentSpawner({
|
|
95067
|
+
parentSession: session,
|
|
95068
|
+
parentTurnId: turnId,
|
|
95069
|
+
parentSignal: signal,
|
|
95070
|
+
parentModel: input.model ?? activeModel(session)
|
|
95071
|
+
});
|
|
95072
|
+
return runWorkflow(
|
|
95073
|
+
entry.workflow,
|
|
95074
|
+
{
|
|
95075
|
+
spawner,
|
|
95076
|
+
tools: createWorkflowToolRunner(session, turnId, spawner),
|
|
95077
|
+
lookup: {
|
|
95078
|
+
skill: (n) => session.skills.byName(n),
|
|
95079
|
+
workflow: (n) => store.lookup(n)
|
|
95080
|
+
},
|
|
95081
|
+
signal,
|
|
95082
|
+
...input.inputs ? { inputs: input.inputs } : {},
|
|
95083
|
+
trigger: input.trigger ?? "auto",
|
|
95084
|
+
now: () => Date.now(),
|
|
95085
|
+
emit: (subtype, payload2) => void session.log.append({
|
|
95086
|
+
type: "plugin_event",
|
|
95087
|
+
sessionId: session.id,
|
|
95088
|
+
turnId,
|
|
95089
|
+
source: "plugin",
|
|
95090
|
+
pluginId: PLUGIN_ID3,
|
|
95091
|
+
subtype,
|
|
95092
|
+
// Stamp the causal chain onto the completion event so the
|
|
95093
|
+
// afterWorkflow subscription can detect cycles/depth per-run.
|
|
95094
|
+
payload: subtype === "workflow_completed" && input.chain && input.chain.length > 0 ? { ...payload2, triggerChain: [...input.chain] } : payload2
|
|
95095
|
+
}),
|
|
95096
|
+
...logger ? { logger } : {}
|
|
94124
95097
|
},
|
|
94125
|
-
|
|
94126
|
-
|
|
94127
|
-
|
|
94128
|
-
|
|
94129
|
-
|
|
94130
|
-
|
|
94131
|
-
|
|
94132
|
-
turnId,
|
|
94133
|
-
source: "plugin",
|
|
94134
|
-
pluginId: PLUGIN_ID3,
|
|
94135
|
-
subtype,
|
|
94136
|
-
// Stamp the causal chain onto the completion event so the
|
|
94137
|
-
// afterWorkflow subscription can detect cycles/depth per-run.
|
|
94138
|
-
payload: subtype === "workflow_completed" && input.chain && input.chain.length > 0 ? { ...payload2, triggerChain: [...input.chain] } : payload2
|
|
94139
|
-
}),
|
|
94140
|
-
...logger ? { logger } : {}
|
|
94141
|
-
},
|
|
94142
|
-
{ executor: session.workflowExecutors.getActive() }
|
|
94143
|
-
);
|
|
95098
|
+
{
|
|
95099
|
+
executor: session.workflowExecutors.getActive(),
|
|
95100
|
+
...args.recordDir ? { recordDir: args.recordDir } : {}
|
|
95101
|
+
}
|
|
95102
|
+
);
|
|
95103
|
+
};
|
|
95104
|
+
const result = await (args.approvalExecution ? args.approvalExecution.run(input.name, String(turnId), parentSignal, execute, entry.workflow) : execute());
|
|
94144
95105
|
if (result.status === "paused") {
|
|
94145
95106
|
logger?.warn?.("workflows: run paused awaiting operator input; not delivering to inbox", {
|
|
94146
95107
|
workflow: input.name,
|
|
@@ -94156,8 +95117,7 @@ function buildWorkflowRunner(args) {
|
|
|
94156
95117
|
}
|
|
94157
95118
|
async function resumeNow(runId, reply) {
|
|
94158
95119
|
const checkpoint = await defaultWorkflowRunStore.load(runId);
|
|
94159
|
-
|
|
94160
|
-
if (!name) {
|
|
95120
|
+
if (!checkpoint || !checkpoint.workflow.name) {
|
|
94161
95121
|
return {
|
|
94162
95122
|
ok: false,
|
|
94163
95123
|
status: "failed",
|
|
@@ -94166,6 +95126,7 @@ function buildWorkflowRunner(args) {
|
|
|
94166
95126
|
error: `no resumable run "${runId}"`
|
|
94167
95127
|
};
|
|
94168
95128
|
}
|
|
95129
|
+
const name = checkpoint.workflow.name;
|
|
94169
95130
|
if (inFlight.has(name)) {
|
|
94170
95131
|
return {
|
|
94171
95132
|
ok: false,
|
|
@@ -94178,41 +95139,47 @@ function buildWorkflowRunner(args) {
|
|
|
94178
95139
|
inFlight.add(name);
|
|
94179
95140
|
try {
|
|
94180
95141
|
const turnId = session.startTurn().turnId;
|
|
94181
|
-
const
|
|
94182
|
-
|
|
94183
|
-
|
|
94184
|
-
|
|
94185
|
-
|
|
94186
|
-
|
|
94187
|
-
|
|
94188
|
-
|
|
94189
|
-
|
|
94190
|
-
|
|
94191
|
-
|
|
94192
|
-
|
|
94193
|
-
|
|
94194
|
-
|
|
94195
|
-
|
|
95142
|
+
const execute = (signal = session.signal) => {
|
|
95143
|
+
const spawner = createSubagentSpawner({
|
|
95144
|
+
parentSession: session,
|
|
95145
|
+
parentTurnId: turnId,
|
|
95146
|
+
parentSignal: signal,
|
|
95147
|
+
parentModel: activeModel(session)
|
|
95148
|
+
});
|
|
95149
|
+
return resumeWorkflowRun(
|
|
95150
|
+
runId,
|
|
95151
|
+
reply,
|
|
95152
|
+
{
|
|
95153
|
+
spawner,
|
|
95154
|
+
tools: createWorkflowToolRunner(session, turnId, spawner),
|
|
95155
|
+
lookup: {
|
|
95156
|
+
skill: (n) => session.skills.byName(n),
|
|
95157
|
+
workflow: (n) => store.lookup(n)
|
|
95158
|
+
},
|
|
95159
|
+
signal,
|
|
95160
|
+
now: () => Date.now(),
|
|
95161
|
+
emit: (subtype, payload2) => void session.log.append({
|
|
95162
|
+
type: "plugin_event",
|
|
95163
|
+
sessionId: session.id,
|
|
95164
|
+
turnId,
|
|
95165
|
+
source: "plugin",
|
|
95166
|
+
pluginId: PLUGIN_ID3,
|
|
95167
|
+
subtype,
|
|
95168
|
+
payload: payload2
|
|
95169
|
+
}),
|
|
95170
|
+
...logger ? { logger } : {}
|
|
94196
95171
|
},
|
|
94197
|
-
|
|
94198
|
-
|
|
94199
|
-
|
|
94200
|
-
|
|
94201
|
-
sessionId: session.id,
|
|
94202
|
-
turnId,
|
|
94203
|
-
source: "plugin",
|
|
94204
|
-
pluginId: PLUGIN_ID3,
|
|
94205
|
-
subtype,
|
|
94206
|
-
payload: payload2
|
|
94207
|
-
}),
|
|
94208
|
-
...logger ? { logger } : {}
|
|
94209
|
-
},
|
|
94210
|
-
defaultWorkflowRunStore
|
|
94211
|
-
);
|
|
95172
|
+
defaultWorkflowRunStore
|
|
95173
|
+
);
|
|
95174
|
+
};
|
|
95175
|
+
const result = await (args.approvalExecution ? args.approvalExecution.run(name, String(turnId), session.signal, execute, checkpoint.workflow) : execute());
|
|
94212
95176
|
if (result.status === "paused") {
|
|
94213
|
-
logger?.warn?.(
|
|
94214
|
-
|
|
94215
|
-
|
|
95177
|
+
logger?.warn?.(
|
|
95178
|
+
"workflows: run paused again awaiting operator input; not delivering to inbox",
|
|
95179
|
+
{
|
|
95180
|
+
runId: result.runId
|
|
95181
|
+
}
|
|
95182
|
+
);
|
|
94216
95183
|
return result;
|
|
94217
95184
|
}
|
|
94218
95185
|
await deliverToInbox(checkpoint.workflow, result, logger);
|
|
@@ -94246,7 +95213,7 @@ async function deliverToInbox(workflow, result, logger) {
|
|
|
94246
95213
|
`workflow: ${workflow.name}`,
|
|
94247
95214
|
`firedAt: ${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
94248
95215
|
workflow.delivery?.channel ? `channel: ${workflow.delivery.channel}` : null,
|
|
94249
|
-
`outcome: ${result.ok ? "ok" : "error"}`,
|
|
95216
|
+
`outcome: ${result.status === "cancelled" ? "cancelled" : result.ok ? "ok" : "error"}`,
|
|
94250
95217
|
"---",
|
|
94251
95218
|
""
|
|
94252
95219
|
].filter((l) => l !== null).join("\n");
|
|
@@ -94281,6 +95248,11 @@ function triggerSummary2(on) {
|
|
|
94281
95248
|
function buildWorkflowsView(args) {
|
|
94282
95249
|
const { store, runner, syncSchedules } = args;
|
|
94283
95250
|
return {
|
|
95251
|
+
delete: async (name) => {
|
|
95252
|
+
const result = await store.delete(name);
|
|
95253
|
+
if (!result.ok) throw new Error(`Cannot delete workflow: ${result.reason}`);
|
|
95254
|
+
await syncSchedules(name);
|
|
95255
|
+
},
|
|
94284
95256
|
list: async () => (await store.list()).map((w) => ({
|
|
94285
95257
|
name: w.workflow.name,
|
|
94286
95258
|
description: w.workflow.description,
|
|
@@ -94350,6 +95322,104 @@ var init_build_workflow_tools = __esm({
|
|
|
94350
95322
|
init_dist35();
|
|
94351
95323
|
}
|
|
94352
95324
|
});
|
|
95325
|
+
function definition(workflow, store, visited = /* @__PURE__ */ new Set()) {
|
|
95326
|
+
if (visited.has(workflow.name)) return { cycle: workflow.name };
|
|
95327
|
+
visited.add(workflow.name);
|
|
95328
|
+
const {
|
|
95329
|
+
name: _name,
|
|
95330
|
+
description: _description,
|
|
95331
|
+
on: _on,
|
|
95332
|
+
enabled: _enabled,
|
|
95333
|
+
...execution
|
|
95334
|
+
} = workflow;
|
|
95335
|
+
return {
|
|
95336
|
+
execution,
|
|
95337
|
+
nested: workflow.steps.filter((step) => step.workflow).map((step) => {
|
|
95338
|
+
const nested = step.workflow ? store.lookup(step.workflow) : void 0;
|
|
95339
|
+
return nested ? definition(nested, store, visited) : null;
|
|
95340
|
+
})
|
|
95341
|
+
};
|
|
95342
|
+
}
|
|
95343
|
+
function buildWorkflowApprovalExecution(cwd2, store, approvalDir = join(moxxyPath("workflow-approvals"), approvalFingerprint(cwd2))) {
|
|
95344
|
+
const approvals = new WorkflowApprovals(approvalDir);
|
|
95345
|
+
const current = new AsyncLocalStorage();
|
|
95346
|
+
const active2 = /* @__PURE__ */ new Map();
|
|
95347
|
+
return {
|
|
95348
|
+
approvals,
|
|
95349
|
+
execution: {
|
|
95350
|
+
async run(name, runId, signal, task, expectedDefinition) {
|
|
95351
|
+
await store.load();
|
|
95352
|
+
const entry = await store.get(name);
|
|
95353
|
+
if (!entry || !entry.workflow.enabled) throw new Error("Workflow is missing or disabled");
|
|
95354
|
+
const revision = approvalFingerprint(definition(entry.workflow, store));
|
|
95355
|
+
if (expectedDefinition && approvalFingerprint(definition(expectedDefinition, store)) !== revision)
|
|
95356
|
+
throw new Error("Workflow definition changed; reload before starting or resuming it");
|
|
95357
|
+
const workflowId = approvalFingerprint([cwd2, entry.path]);
|
|
95358
|
+
const inherited = current.getStore();
|
|
95359
|
+
if (inherited && inherited.scope.workflowId === workflowId)
|
|
95360
|
+
return task(AbortSignal.any([signal, inherited.signal]));
|
|
95361
|
+
if (active2.has(workflowId))
|
|
95362
|
+
throw new Error(
|
|
95363
|
+
"Workflow execution skipped: another execution is running or awaiting approval"
|
|
95364
|
+
);
|
|
95365
|
+
const release = await claimWorkflowLease(join(approvalDir, "leases"), workflowId, signal);
|
|
95366
|
+
try {
|
|
95367
|
+
const scope2 = { workflowId, workflowName: name, revision, runId };
|
|
95368
|
+
const controller = new AbortController();
|
|
95369
|
+
const effectiveSignal = AbortSignal.any([signal, controller.signal]);
|
|
95370
|
+
active2.set(workflowId, runId);
|
|
95371
|
+
const valid = async () => {
|
|
95372
|
+
if (await approvals.isCancelled(scope2)) controller.abort("Workflow stopped");
|
|
95373
|
+
await store.load();
|
|
95374
|
+
const updated = await store.get(name);
|
|
95375
|
+
return !effectiveSignal.aborted && !!updated && updated.workflow.enabled && approvalFingerprint(definition(updated.workflow, store)) === revision;
|
|
95376
|
+
};
|
|
95377
|
+
let checking = false;
|
|
95378
|
+
const timer = setInterval(() => {
|
|
95379
|
+
if (checking) return;
|
|
95380
|
+
checking = true;
|
|
95381
|
+
void valid().then((ok) => {
|
|
95382
|
+
if (!ok) controller.abort("Workflow changed or stopped");
|
|
95383
|
+
}).catch((error) => controller.abort(error)).finally(() => {
|
|
95384
|
+
checking = false;
|
|
95385
|
+
});
|
|
95386
|
+
}, 200);
|
|
95387
|
+
timer.unref();
|
|
95388
|
+
try {
|
|
95389
|
+
return await current.run(
|
|
95390
|
+
{ scope: scope2, signal: effectiveSignal },
|
|
95391
|
+
() => withPermissionScope(
|
|
95392
|
+
{
|
|
95393
|
+
name: "workflow-scoped-approval",
|
|
95394
|
+
check: async (call) => {
|
|
95395
|
+
if (!await valid())
|
|
95396
|
+
return { mode: "deny", reason: "Workflow changed, disabled or cancelled" };
|
|
95397
|
+
const decision = await approvals.check(scope2, call, effectiveSignal, valid);
|
|
95398
|
+
if (await approvals.isCancelled(scope2)) controller.abort("Workflow stopped");
|
|
95399
|
+
return decision;
|
|
95400
|
+
}
|
|
95401
|
+
},
|
|
95402
|
+
() => task(effectiveSignal)
|
|
95403
|
+
)
|
|
95404
|
+
);
|
|
95405
|
+
} finally {
|
|
95406
|
+
clearInterval(timer);
|
|
95407
|
+
controller.abort("Workflow ended");
|
|
95408
|
+
active2.delete(workflowId);
|
|
95409
|
+
await approvals.finishRun(runId);
|
|
95410
|
+
}
|
|
95411
|
+
} finally {
|
|
95412
|
+
await release();
|
|
95413
|
+
}
|
|
95414
|
+
}
|
|
95415
|
+
}
|
|
95416
|
+
};
|
|
95417
|
+
}
|
|
95418
|
+
var init_workflow_approval_scope = __esm({
|
|
95419
|
+
"src/setup/workflow-approval-scope.ts"() {
|
|
95420
|
+
init_dist2();
|
|
95421
|
+
}
|
|
95422
|
+
});
|
|
94353
95423
|
function detectAfterWorkflowCycles(workflows) {
|
|
94354
95424
|
const enabled = /* @__PURE__ */ new Map();
|
|
94355
95425
|
for (const w of workflows) if (w.enabled) enabled.set(w.name, w);
|
|
@@ -94535,7 +95605,14 @@ function wireWorkflowTriggers(args) {
|
|
|
94535
95605
|
}
|
|
94536
95606
|
}
|
|
94537
95607
|
}
|
|
94538
|
-
async function syncSchedules() {
|
|
95608
|
+
async function syncSchedules(deletedName) {
|
|
95609
|
+
if (deletedName) {
|
|
95610
|
+
for (const entry of await scheduleStore.list()) {
|
|
95611
|
+
if (entry.source === "workflow" && entry.workflowName === deletedName) {
|
|
95612
|
+
await scheduleStore.delete(entry.id);
|
|
95613
|
+
}
|
|
95614
|
+
}
|
|
95615
|
+
}
|
|
94539
95616
|
const all = await store.list();
|
|
94540
95617
|
applyAfterWorkflowCycleGuard({
|
|
94541
95618
|
workflows: all.map((w) => w.workflow),
|
|
@@ -94654,7 +95731,10 @@ function buildWorkflowsIntegration(args) {
|
|
|
94654
95731
|
builtinDir: BUILTIN_WORKFLOWS_DIR,
|
|
94655
95732
|
...logger ? { logger } : {}
|
|
94656
95733
|
});
|
|
94657
|
-
const
|
|
95734
|
+
const { approvals, execution } = buildWorkflowApprovalExecution(session.cwd, store);
|
|
95735
|
+
session.services.register("workflowApprovalExecution", execution);
|
|
95736
|
+
const runner = buildWorkflowRunner({ session, store, approvalExecution: execution, ...logger ? { logger } : {} });
|
|
95737
|
+
session.services.register("workflowRunner", runner);
|
|
94658
95738
|
const fileLock = ownerSessionId ? new CrossProcessFireLock({ dir: moxxyPath("locks", "workflow-triggers"), ttlMs: 3e3 }) : void 0;
|
|
94659
95739
|
const triggers = wireWorkflowTriggers({
|
|
94660
95740
|
session,
|
|
@@ -94667,11 +95747,19 @@ function buildWorkflowsIntegration(args) {
|
|
|
94667
95747
|
...ownerSessionId ? { thisRunnerSessionId: ownerSessionId } : {},
|
|
94668
95748
|
...logger ? { logger } : {}
|
|
94669
95749
|
});
|
|
94670
|
-
const view = buildWorkflowsView({ store, runner, syncSchedules: triggers.syncSchedules });
|
|
95750
|
+
const view = { ...buildWorkflowsView({ store, runner, syncSchedules: triggers.syncSchedules }), approvals };
|
|
94671
95751
|
const built = buildWorkflowsPlugin({
|
|
94672
95752
|
store,
|
|
94673
95753
|
skills: session.skills,
|
|
94674
95754
|
tools: session.tools,
|
|
95755
|
+
toolsForTurn: (ctx) => createWorkflowToolRunner(session, ctx.turnId, ctx.subagents),
|
|
95756
|
+
runScoped: (name, ctx, task, definition2) => execution.run(name, String(ctx.turnId), ctx.signal, task, definition2),
|
|
95757
|
+
subagentsForTurn: (turnId, signal) => createSubagentSpawner({
|
|
95758
|
+
parentSession: session,
|
|
95759
|
+
parentTurnId: turnId,
|
|
95760
|
+
parentSignal: signal,
|
|
95761
|
+
parentModel: activeModel(session)
|
|
95762
|
+
}),
|
|
94675
95763
|
getActiveExecutor: () => session.workflowExecutors.getActive(),
|
|
94676
95764
|
appendEvent: (e2) => session.log.append(e2),
|
|
94677
95765
|
...logger ? { logger } : {},
|
|
@@ -94715,6 +95803,7 @@ var init_workflows2 = __esm({
|
|
|
94715
95803
|
init_dist35();
|
|
94716
95804
|
init_build_workflow_runner();
|
|
94717
95805
|
init_build_workflow_tools();
|
|
95806
|
+
init_workflow_approval_scope();
|
|
94718
95807
|
init_wire_run_store();
|
|
94719
95808
|
}
|
|
94720
95809
|
});
|
|
@@ -94977,25 +96066,45 @@ var init_builtins = __esm({
|
|
|
94977
96066
|
// src/setup/scheduler-runner.ts
|
|
94978
96067
|
function buildSchedulerRunner(session) {
|
|
94979
96068
|
return {
|
|
94980
|
-
runPrompt: async ({ prompt, model, origin }) => {
|
|
94981
|
-
|
|
94982
|
-
|
|
94983
|
-
|
|
94984
|
-
|
|
94985
|
-
|
|
94986
|
-
|
|
94987
|
-
|
|
94988
|
-
|
|
94989
|
-
|
|
94990
|
-
|
|
94991
|
-
|
|
94992
|
-
|
|
94993
|
-
}
|
|
96069
|
+
runPrompt: async ({ prompt, model, origin, signal }) => {
|
|
96070
|
+
if (origin?.kind === "workflow") {
|
|
96071
|
+
const runner = session.services.get("workflowRunner");
|
|
96072
|
+
if (!runner) return { text: "", error: "Workflow runner is not ready" };
|
|
96073
|
+
try {
|
|
96074
|
+
const result = await runner.runNow({
|
|
96075
|
+
name: origin.name,
|
|
96076
|
+
trigger: "schedule",
|
|
96077
|
+
...model ? { model } : {},
|
|
96078
|
+
...signal ? { signal } : {}
|
|
96079
|
+
});
|
|
96080
|
+
return { text: result.output, ...result.status === "cancelled" ? { cancelled: true } : {}, ...result.error ? { error: result.error } : {} };
|
|
96081
|
+
} catch (error) {
|
|
96082
|
+
return { text: "", error: error instanceof Error ? error.message : String(error) };
|
|
94994
96083
|
}
|
|
94995
|
-
} catch (err) {
|
|
94996
|
-
return { text: text2, error: err instanceof Error ? err.message : String(err) };
|
|
94997
96084
|
}
|
|
94998
|
-
|
|
96085
|
+
const turnId = session.startTurn().turnId;
|
|
96086
|
+
const execute = async () => {
|
|
96087
|
+
let text2 = "";
|
|
96088
|
+
let lastError = null;
|
|
96089
|
+
try {
|
|
96090
|
+
for await (const event of runTurn(session, prompt, {
|
|
96091
|
+
turnId,
|
|
96092
|
+
...origin ? { origin } : {},
|
|
96093
|
+
...model ? { model } : {}
|
|
96094
|
+
})) {
|
|
96095
|
+
if (event.type === "assistant_message") {
|
|
96096
|
+
text2 = event.content;
|
|
96097
|
+
lastError = event.stopReason === "error" ? "turn ended with error stop reason" : null;
|
|
96098
|
+
} else if (event.type === "error") {
|
|
96099
|
+
lastError = event.message;
|
|
96100
|
+
}
|
|
96101
|
+
}
|
|
96102
|
+
} catch (err) {
|
|
96103
|
+
return { text: text2, error: err instanceof Error ? err.message : String(err) };
|
|
96104
|
+
}
|
|
96105
|
+
return lastError ? { text: text2, error: lastError } : { text: text2 };
|
|
96106
|
+
};
|
|
96107
|
+
return execute();
|
|
94999
96108
|
}
|
|
95000
96109
|
};
|
|
95001
96110
|
}
|
|
@@ -95782,7 +96891,7 @@ function _t(t, e2) {
|
|
|
95782
96891
|
return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
|
|
95783
96892
|
}
|
|
95784
96893
|
function Ct(t) {
|
|
95785
|
-
return t ===
|
|
96894
|
+
return t === z63;
|
|
95786
96895
|
}
|
|
95787
96896
|
function T(t, e2) {
|
|
95788
96897
|
const s = t;
|
|
@@ -95826,7 +96935,7 @@ function Dt(t, e2) {
|
|
|
95826
96935
|
function St(t, e2) {
|
|
95827
96936
|
if (e2) return t ? e2 : e2[0];
|
|
95828
96937
|
}
|
|
95829
|
-
var import_picocolors, import_sisteransi, at, lt, ht, O, y, L, P, M, ct, ft, X, pt, S, W, Z, Ft, j, Q, dt, tt, U, et, mt, st, it, gt, G, vt, Et, At, _, bt,
|
|
96938
|
+
var import_picocolors, import_sisteransi, at, lt, ht, O, y, L, P, M, ct, ft, X, pt, S, W, Z, Ft, j, Q, dt, tt, U, et, mt, st, it, gt, G, vt, Et, At, _, bt, z63, rt, nt, x, Vt, kt, yt, Lt, Mt, Wt, Tt, $t;
|
|
95830
96939
|
var init_dist36 = __esm({
|
|
95831
96940
|
"../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs"() {
|
|
95832
96941
|
import_picocolors = __toESM(require_picocolors());
|
|
@@ -95993,7 +97102,7 @@ var init_dist36 = __esm({
|
|
|
95993
97102
|
At = ["up", "down", "left", "right", "space", "enter", "cancel"];
|
|
95994
97103
|
_ = { actions: new Set(At), aliases: /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true };
|
|
95995
97104
|
bt = globalThis.process.platform.startsWith("win");
|
|
95996
|
-
|
|
97105
|
+
z63 = /* @__PURE__ */ Symbol("clack:cancel");
|
|
95997
97106
|
rt = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80;
|
|
95998
97107
|
nt = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
|
|
95999
97108
|
x = class {
|
|
@@ -96036,7 +97145,7 @@ var init_dist36 = __esm({
|
|
|
96036
97145
|
prompt() {
|
|
96037
97146
|
return new Promise((e2) => {
|
|
96038
97147
|
if (this._abortSignal) {
|
|
96039
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e2(
|
|
97148
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e2(z63);
|
|
96040
97149
|
this._abortSignal.addEventListener("abort", () => {
|
|
96041
97150
|
this.state = "cancel", this.close();
|
|
96042
97151
|
}, { once: true });
|
|
@@ -96044,7 +97153,7 @@ var init_dist36 = __esm({
|
|
|
96044
97153
|
this.rl = k__default.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), T(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
96045
97154
|
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(this.value);
|
|
96046
97155
|
}), this.once("cancel", () => {
|
|
96047
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(
|
|
97156
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), T(this.input, false), e2(z63);
|
|
96048
97157
|
});
|
|
96049
97158
|
});
|
|
96050
97159
|
}
|
|
@@ -101267,9 +102376,9 @@ async function runConfigCommand(argv) {
|
|
|
101267
102376
|
return 0;
|
|
101268
102377
|
}
|
|
101269
102378
|
const sub = argv.positional[0];
|
|
101270
|
-
const
|
|
101271
|
-
if (
|
|
101272
|
-
printError(`invalid --scope: ${
|
|
102379
|
+
const scope2 = stringFlag(argv, "scope") ?? "user";
|
|
102380
|
+
if (scope2 !== "user" && scope2 !== "project") {
|
|
102381
|
+
printError(`invalid --scope: ${scope2} (use user|project)`);
|
|
101273
102382
|
return 2;
|
|
101274
102383
|
}
|
|
101275
102384
|
switch (sub) {
|
|
@@ -101302,7 +102411,7 @@ async function runConfigCommand(argv) {
|
|
|
101302
102411
|
}
|
|
101303
102412
|
try {
|
|
101304
102413
|
const res = await setConfigValue({
|
|
101305
|
-
scope,
|
|
102414
|
+
scope: scope2,
|
|
101306
102415
|
cwd: process.cwd(),
|
|
101307
102416
|
path: dotPath,
|
|
101308
102417
|
value: parseValue2(raw)
|
|
@@ -105478,10 +106587,10 @@ async function runSkillsCommand(argv) {
|
|
|
105478
106587
|
const usedCol = Math.max(4, ...skills.map((s) => usedFor(s).length));
|
|
105479
106588
|
for (const s of skills) {
|
|
105480
106589
|
const name = colors.bold(s.frontmatter.name.padEnd(nameCol));
|
|
105481
|
-
const
|
|
106590
|
+
const scope2 = colors.dim(s.scope.padEnd(scopeCol));
|
|
105482
106591
|
const used = colors.dim(usedFor(s).padStart(usedCol));
|
|
105483
106592
|
const desc = colors.dim(s.frontmatter.description);
|
|
105484
|
-
process.stdout.write(`${name} ${
|
|
106593
|
+
process.stdout.write(`${name} ${scope2} ${used} ${desc}
|
|
105485
106594
|
`);
|
|
105486
106595
|
}
|
|
105487
106596
|
return 0;
|
|
@@ -106560,7 +107669,7 @@ async function waitForChannelStatus(name, def) {
|
|
|
106560
107669
|
while (Date.now() < deadline) {
|
|
106561
107670
|
const status = liveChannelStatus(name);
|
|
106562
107671
|
if (status && (!needsUrl || status.requestUrl)) return status;
|
|
106563
|
-
await
|
|
107672
|
+
await delay3(POLL_MS2);
|
|
106564
107673
|
}
|
|
106565
107674
|
return liveChannelStatus(name);
|
|
106566
107675
|
}
|
|
@@ -106568,7 +107677,7 @@ async function waitForChannelGone(name) {
|
|
|
106568
107677
|
const deadline = Date.now() + STOP_GRACE_MS2;
|
|
106569
107678
|
while (Date.now() < deadline) {
|
|
106570
107679
|
if (!liveChannelStatus(name)) return true;
|
|
106571
|
-
await
|
|
107680
|
+
await delay3(POLL_MS2);
|
|
106572
107681
|
}
|
|
106573
107682
|
return liveChannelStatus(name) === null;
|
|
106574
107683
|
}
|
|
@@ -106611,7 +107720,7 @@ function formatSubcommandHelp(channelName, subName, sub) {
|
|
|
106611
107720
|
lines.push(` ${colors.dim(sub.description)}`);
|
|
106612
107721
|
return lines.join("\n") + "\n";
|
|
106613
107722
|
}
|
|
106614
|
-
var HELP20, START_TIMEOUT_MS2, STOP_GRACE_MS2, POLL_MS2,
|
|
107723
|
+
var HELP20, START_TIMEOUT_MS2, STOP_GRACE_MS2, POLL_MS2, delay3;
|
|
106615
107724
|
var init_channels2 = __esm({
|
|
106616
107725
|
async "src/commands/channels.ts"() {
|
|
106617
107726
|
await init_argv_helpers();
|
|
@@ -106641,7 +107750,7 @@ var init_channels2 = __esm({
|
|
|
106641
107750
|
START_TIMEOUT_MS2 = 15e3;
|
|
106642
107751
|
STOP_GRACE_MS2 = 4e3;
|
|
106643
107752
|
POLL_MS2 = 300;
|
|
106644
|
-
|
|
107753
|
+
delay3 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
106645
107754
|
}
|
|
106646
107755
|
});
|
|
106647
107756
|
|