@paigy/harness 0.3.12 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +323 -2745
- package/dist/main.js +326 -2747
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
15
15
|
var __esm = (fn, res) => function __init() {
|
|
16
16
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
17
|
};
|
|
18
|
-
var __commonJS = (cb, mod) => function
|
|
18
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
19
19
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
20
20
|
};
|
|
21
21
|
var __export = (target, all) => {
|
|
@@ -13412,11 +13412,11 @@ var require_readable = __commonJS({
|
|
|
13412
13412
|
});
|
|
13413
13413
|
}
|
|
13414
13414
|
};
|
|
13415
|
-
function isLocked(
|
|
13416
|
-
return
|
|
13415
|
+
function isLocked(self) {
|
|
13416
|
+
return self[kBody] && self[kBody].locked === true || self[kConsume];
|
|
13417
13417
|
}
|
|
13418
|
-
function isUnusable(
|
|
13419
|
-
return util2.isDisturbed(
|
|
13418
|
+
function isUnusable(self) {
|
|
13419
|
+
return util2.isDisturbed(self) || isLocked(self);
|
|
13420
13420
|
}
|
|
13421
13421
|
async function consume(stream, type) {
|
|
13422
13422
|
assert(!stream[kConsume]);
|
|
@@ -13805,42 +13805,42 @@ var require_abort_signal = __commonJS({
|
|
|
13805
13805
|
var { RequestAbortedError } = require_errors();
|
|
13806
13806
|
var kListener = /* @__PURE__ */ Symbol("kListener");
|
|
13807
13807
|
var kSignal = /* @__PURE__ */ Symbol("kSignal");
|
|
13808
|
-
function abort(
|
|
13809
|
-
if (
|
|
13810
|
-
|
|
13808
|
+
function abort(self) {
|
|
13809
|
+
if (self.abort) {
|
|
13810
|
+
self.abort(self[kSignal]?.reason);
|
|
13811
13811
|
} else {
|
|
13812
|
-
|
|
13812
|
+
self.reason = self[kSignal]?.reason ?? new RequestAbortedError();
|
|
13813
13813
|
}
|
|
13814
|
-
removeSignal(
|
|
13814
|
+
removeSignal(self);
|
|
13815
13815
|
}
|
|
13816
|
-
function addSignal(
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13816
|
+
function addSignal(self, signal) {
|
|
13817
|
+
self.reason = null;
|
|
13818
|
+
self[kSignal] = null;
|
|
13819
|
+
self[kListener] = null;
|
|
13820
13820
|
if (!signal) {
|
|
13821
13821
|
return;
|
|
13822
13822
|
}
|
|
13823
13823
|
if (signal.aborted) {
|
|
13824
|
-
abort(
|
|
13824
|
+
abort(self);
|
|
13825
13825
|
return;
|
|
13826
13826
|
}
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
abort(
|
|
13827
|
+
self[kSignal] = signal;
|
|
13828
|
+
self[kListener] = () => {
|
|
13829
|
+
abort(self);
|
|
13830
13830
|
};
|
|
13831
|
-
addAbortListener(
|
|
13831
|
+
addAbortListener(self[kSignal], self[kListener]);
|
|
13832
13832
|
}
|
|
13833
|
-
function removeSignal(
|
|
13834
|
-
if (!
|
|
13833
|
+
function removeSignal(self) {
|
|
13834
|
+
if (!self[kSignal]) {
|
|
13835
13835
|
return;
|
|
13836
13836
|
}
|
|
13837
|
-
if ("removeEventListener" in
|
|
13838
|
-
|
|
13837
|
+
if ("removeEventListener" in self[kSignal]) {
|
|
13838
|
+
self[kSignal].removeEventListener("abort", self[kListener]);
|
|
13839
13839
|
} else {
|
|
13840
|
-
|
|
13840
|
+
self[kSignal].removeListener("abort", self[kListener]);
|
|
13841
13841
|
}
|
|
13842
|
-
|
|
13843
|
-
|
|
13842
|
+
self[kSignal] = null;
|
|
13843
|
+
self[kListener] = null;
|
|
13844
13844
|
}
|
|
13845
13845
|
module.exports = {
|
|
13846
13846
|
addSignal,
|
|
@@ -22744,22 +22744,53 @@ var require_undici = __commonJS({
|
|
|
22744
22744
|
|
|
22745
22745
|
// ../../packages/sdk/dist/index.js
|
|
22746
22746
|
import { createRequire as __sdkCreateRequire } from "module";
|
|
22747
|
+
import { execFileSync } from "child_process";
|
|
22747
22748
|
import { createHash, randomUUID } from "crypto";
|
|
22749
|
+
import { readFileSync } from "fs";
|
|
22750
|
+
import { homedir as homedir2 } from "os";
|
|
22751
|
+
import { join as join2 } from "path";
|
|
22748
22752
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
22749
22753
|
import { setTimeout as sleep2 } from "timers/promises";
|
|
22750
22754
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
22751
|
-
import { closeSync, existsSync as existsSync2, mkdirSync, openSync, readFileSync, rmSync, statSync, writeFileSync } from "fs";
|
|
22752
|
-
import { homedir as
|
|
22753
|
-
import { join as
|
|
22755
|
+
import { closeSync, existsSync as existsSync2, mkdirSync, openSync, readFileSync as readFileSync2, rmSync, statSync, writeFileSync } from "fs";
|
|
22756
|
+
import { homedir as homedir22 } from "os";
|
|
22757
|
+
import { join as join22 } from "path";
|
|
22754
22758
|
async function proxy() {
|
|
22755
22759
|
if (!PROXY_ENV.some((k) => process.env[k])) return void 0;
|
|
22756
22760
|
return agent ??= new (await Promise.resolve().then(() => __toESM(require_undici(), 1))).EnvHttpProxyAgent();
|
|
22757
22761
|
}
|
|
22762
|
+
function parentOf(pid) {
|
|
22763
|
+
try {
|
|
22764
|
+
if (process.platform === "win32") return void 0;
|
|
22765
|
+
const ppid = process.platform === "linux" ? readFileSync(`/proc/${pid}/stat`, "utf8").split(") ")[1]?.split(" ")[1] : execFileSync("ps", ["-o", "ppid=", "-p", String(pid)], { encoding: "utf8", timeout: 1e3 });
|
|
22766
|
+
return Number(ppid?.trim()) || void 0;
|
|
22767
|
+
} catch {
|
|
22768
|
+
return void 0;
|
|
22769
|
+
}
|
|
22770
|
+
}
|
|
22771
|
+
function ancestors() {
|
|
22772
|
+
if (lineage) return lineage;
|
|
22773
|
+
lineage = [];
|
|
22774
|
+
for (let pid = process.ppid; pid && pid > 1 && lineage.length < 5; pid = parentOf(pid)) lineage.push(pid);
|
|
22775
|
+
return lineage;
|
|
22776
|
+
}
|
|
22777
|
+
function claudeConversation() {
|
|
22778
|
+
if (!envSession("CLAUDE_CODE_SESSION_ID") || process.env.CLAUDE_CODE_CHILD_SESSION) return void 0;
|
|
22779
|
+
const dir = envSession("CLAUDE_CONFIG_DIR") ?? join2(homedir2(), ".claude");
|
|
22780
|
+
for (const pid of ancestors()) {
|
|
22781
|
+
try {
|
|
22782
|
+
const { sessionId: sessionId2 } = JSON.parse(readFileSync(join2(dir, "sessions", `${pid}.json`), "utf8"));
|
|
22783
|
+
return typeof sessionId2 === "string" && sessionId2.trim() ? sessionId2 : void 0;
|
|
22784
|
+
} catch {
|
|
22785
|
+
}
|
|
22786
|
+
}
|
|
22787
|
+
return void 0;
|
|
22788
|
+
}
|
|
22758
22789
|
function sessionId() {
|
|
22759
|
-
return
|
|
22790
|
+
return envSession("PAIGY_SESSION_ID") ?? claudeConversation() ?? envSession("CLAUDE_CODE_SESSION_ID") ?? envSession("CODEX_THREAD_ID") ?? envSession("CODEX_SESSION_ID") ?? WORKSPACE_ID;
|
|
22760
22791
|
}
|
|
22761
22792
|
async function reach(url, init) {
|
|
22762
|
-
return send(url, init,
|
|
22793
|
+
return send(url, init, sessionId());
|
|
22763
22794
|
}
|
|
22764
22795
|
function reachAs(session) {
|
|
22765
22796
|
return (url, init) => send(url, init, session);
|
|
@@ -23654,69 +23685,17 @@ function mcpInputSchema(s) {
|
|
|
23654
23685
|
delete schema.$schema;
|
|
23655
23686
|
return draft2020(schema);
|
|
23656
23687
|
}
|
|
23657
|
-
function normalizeWaiting(req) {
|
|
23658
|
-
if (!req.waiting) return req;
|
|
23659
|
-
const { waiting, ...rest } = req;
|
|
23660
|
-
return {
|
|
23661
|
-
...rest,
|
|
23662
|
-
urgencyHint: req.urgencyHint ?? { none: "whenever", soft: "soon", hard: "now" }[waiting],
|
|
23663
|
-
blocking: req.blocking || waiting === "hard"
|
|
23664
|
-
};
|
|
23665
|
-
}
|
|
23666
|
-
function unitsOf(text) {
|
|
23667
|
-
const spans = [];
|
|
23668
|
-
const re = /\n\s*\n+/g;
|
|
23669
|
-
let cursor = 0;
|
|
23670
|
-
const push = (from, to) => {
|
|
23671
|
-
const slice = text.slice(from, to);
|
|
23672
|
-
const lead = slice.length - slice.trimStart().length;
|
|
23673
|
-
const tail = slice.length - slice.trimEnd().length;
|
|
23674
|
-
if (from + lead < to - tail) spans.push({ start: from + lead, end: to - tail });
|
|
23675
|
-
};
|
|
23676
|
-
for (let m = re.exec(text); m; m = re.exec(text)) {
|
|
23677
|
-
push(cursor, m.index);
|
|
23678
|
-
cursor = m.index + m[0].length;
|
|
23679
|
-
}
|
|
23680
|
-
push(cursor, text.length);
|
|
23681
|
-
return spans;
|
|
23682
|
-
}
|
|
23683
|
-
function headline(text) {
|
|
23684
|
-
const line = text.split("\n").map((l) => l.trim()).filter((l) => l && !/^`{3,}/.test(l)).map((l) => l.replace(/^(?:#{1,6}|[-*>]|\d{1,3}\.)\s+/, "")).find(Boolean) ?? "";
|
|
23685
|
-
return (/^[^.!?\n]+[.!?]?/.exec(line)?.[0] ?? line).trim();
|
|
23686
|
-
}
|
|
23687
|
-
function bodyAfterHeadline(text) {
|
|
23688
|
-
const body = text.trim();
|
|
23689
|
-
const title = headline(body);
|
|
23690
|
-
const rest = body.slice(title.length).replace(/^[\s.!?—–-]+/, "").trim();
|
|
23691
|
-
if (!rest) return { title, description: [] };
|
|
23692
|
-
const chunks = unitsOf(rest).map((u) => rest.slice(u.start, u.end)).filter(Boolean);
|
|
23693
|
-
return { title, description: chunks.length ? chunks : [rest] };
|
|
23694
|
-
}
|
|
23695
|
-
function deriveAsk(req) {
|
|
23696
|
-
req = normalizeWaiting(req);
|
|
23697
|
-
if (!req.ask) return req;
|
|
23698
|
-
const text = req.ask.trim();
|
|
23699
|
-
const hinted = req.urgencyHint === "now" ? "call" : req.urgencyHint === "soon" ? "banner" : req.urgencyHint === "whenever" ? "inbox" : req.urgency;
|
|
23700
|
-
const urgency = req.channel === "call" ? "call" : req.channel === "message" && hinted === "call" ? "banner" : hinted;
|
|
23701
|
-
const { ask: _ask, needs, urgencyHint: _hint, channel: _channel, ...rest } = req;
|
|
23702
|
-
return {
|
|
23703
|
-
...rest,
|
|
23704
|
-
context: bodyAfterHeadline(text),
|
|
23705
|
-
// Options riding alongside the ask (#575: pixels can't be prose) floor to a
|
|
23706
|
-
// single pick — the model broker may upgrade to many/rank from the wording.
|
|
23707
|
-
select: req.options?.length ? "one" : "text",
|
|
23708
|
-
urgency,
|
|
23709
|
-
...needs?.length ? { points: needs } : {}
|
|
23710
|
-
};
|
|
23711
|
-
}
|
|
23712
23688
|
function sessionSlot(sessionId2) {
|
|
23713
23689
|
const id = sessionId2 ?? sessionId();
|
|
23714
23690
|
return `session:${id.slice(0, 8)}`;
|
|
23715
23691
|
}
|
|
23692
|
+
function agentName() {
|
|
23693
|
+
return process.env.PAIGY_AGENT || sessionSlot();
|
|
23694
|
+
}
|
|
23716
23695
|
function readTokenFile() {
|
|
23717
23696
|
if (!existsSync2(TOKEN_PATH)) return {};
|
|
23718
23697
|
try {
|
|
23719
|
-
const parsed = JSON.parse(
|
|
23698
|
+
const parsed = JSON.parse(readFileSync2(TOKEN_PATH, "utf8"));
|
|
23720
23699
|
if (typeof parsed.access_token === "string") return {};
|
|
23721
23700
|
const slots = parsed;
|
|
23722
23701
|
delete slots["*"];
|
|
@@ -23728,7 +23707,7 @@ function readTokenFile() {
|
|
|
23728
23707
|
function withTokenLock(mutate) {
|
|
23729
23708
|
const lock = TOKEN_PATH + ".lock";
|
|
23730
23709
|
const spin = new Int32Array(new SharedArrayBuffer(4));
|
|
23731
|
-
mkdirSync(
|
|
23710
|
+
mkdirSync(join22(homedir22(), ".paigy"), { recursive: true });
|
|
23732
23711
|
for (const deadline = Date.now() + 5e3; Date.now() < deadline; ) {
|
|
23733
23712
|
try {
|
|
23734
23713
|
closeSync(openSync(lock, "wx"));
|
|
@@ -23745,7 +23724,7 @@ function withTokenLock(mutate) {
|
|
|
23745
23724
|
rmSync(lock, { force: true });
|
|
23746
23725
|
}
|
|
23747
23726
|
}
|
|
23748
|
-
function saveToken(token, agent2 =
|
|
23727
|
+
function saveToken(token, agent2 = agentName()) {
|
|
23749
23728
|
withTokenLock(() => {
|
|
23750
23729
|
const slots = { ...readTokenFile(), [agent2]: token };
|
|
23751
23730
|
writeFileSync(TOKEN_PATH, JSON.stringify(slots, null, 2) + "\n", { mode: 384 });
|
|
@@ -23765,7 +23744,7 @@ function slotIdentity(agent2) {
|
|
|
23765
23744
|
const t = readTokenFile()[agent2];
|
|
23766
23745
|
return { name: t?.name ?? null, voice: t?.voice ?? null, tokenId: t?.token_id ?? null, workspace: t?.workspace ?? null };
|
|
23767
23746
|
}
|
|
23768
|
-
function readToken(agent2 =
|
|
23747
|
+
function readToken(agent2 = agentName()) {
|
|
23769
23748
|
if (process.env.PAIGY_TOKEN) return process.env.PAIGY_TOKEN;
|
|
23770
23749
|
return readTokenFile()[agent2]?.access_token ?? "";
|
|
23771
23750
|
}
|
|
@@ -23775,24 +23754,23 @@ function listSlots() {
|
|
|
23775
23754
|
function slotName(agent2) {
|
|
23776
23755
|
return readTokenFile()[agent2]?.name ?? null;
|
|
23777
23756
|
}
|
|
23778
|
-
async function requestCode(suggestedName =
|
|
23757
|
+
async function requestCode(suggestedName = agentName(), device) {
|
|
23779
23758
|
const res = await reach(`${BACKEND_URL}/api/device/code`, {
|
|
23780
23759
|
method: "POST",
|
|
23781
23760
|
headers: { "content-type": "application/json" },
|
|
23782
23761
|
body: JSON.stringify({
|
|
23783
23762
|
suggestedName,
|
|
23784
|
-
...device ? { device } : {}
|
|
23785
|
-
...e2ee ? { proto: e2ee.proto, commitment: e2ee.commitment } : {}
|
|
23763
|
+
...device ? { device } : {}
|
|
23786
23764
|
})
|
|
23787
23765
|
});
|
|
23788
23766
|
if (!res.ok) throw new Error(`/api/device/code failed: ${res.status} ${await res.text()}`);
|
|
23789
23767
|
return await res.json();
|
|
23790
23768
|
}
|
|
23791
|
-
async function pollToken(deviceCode
|
|
23769
|
+
async function pollToken(deviceCode) {
|
|
23792
23770
|
const res = await reach(`${BACKEND_URL}/api/device/token`, {
|
|
23793
23771
|
method: "POST",
|
|
23794
23772
|
headers: { "content-type": "application/json" },
|
|
23795
|
-
body: JSON.stringify(
|
|
23773
|
+
body: JSON.stringify({ device_code: deviceCode })
|
|
23796
23774
|
});
|
|
23797
23775
|
if (res.ok) return await res.json();
|
|
23798
23776
|
const body = await res.json().catch(() => ({ error: "unknown" }));
|
|
@@ -23804,14 +23782,6 @@ async function pollToken(deviceCode, reveal) {
|
|
|
23804
23782
|
if (err === "access_denied") throw new Error("Access denied by user. Pairing cancelled.");
|
|
23805
23783
|
throw new Error(`Unexpected error from /api/device/token: ${err}`);
|
|
23806
23784
|
}
|
|
23807
|
-
function readKeyFile() {
|
|
23808
|
-
if (!existsSync2(KEY_PATH)) return null;
|
|
23809
|
-
try {
|
|
23810
|
-
return JSON.parse(readFileSync(KEY_PATH, "utf8"));
|
|
23811
|
-
} catch {
|
|
23812
|
-
return null;
|
|
23813
|
-
}
|
|
23814
|
-
}
|
|
23815
23785
|
function ensureAuthed(res) {
|
|
23816
23786
|
if (res.status === 401) throw new UnpairedError();
|
|
23817
23787
|
return res;
|
|
@@ -23819,6 +23789,16 @@ function ensureAuthed(res) {
|
|
|
23819
23789
|
async function fail(what, res) {
|
|
23820
23790
|
throw new ApiError(what, res.status, await res.text());
|
|
23821
23791
|
}
|
|
23792
|
+
async function createGoal(input, opts = {}) {
|
|
23793
|
+
const token = authToken(opts.token) ?? "";
|
|
23794
|
+
const res = ensureAuthed(await (opts.reach ?? reach)(`${BACKEND_URL}/api/goals`, {
|
|
23795
|
+
method: "POST",
|
|
23796
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${token}`, "x-paigy-model": "goal-entry-v1" },
|
|
23797
|
+
body: JSON.stringify(input)
|
|
23798
|
+
}));
|
|
23799
|
+
if (!res.ok) await fail("create_goal", res);
|
|
23800
|
+
return await res.json();
|
|
23801
|
+
}
|
|
23822
23802
|
async function claimGoal(goalId, opts = {}) {
|
|
23823
23803
|
const token = authToken(opts.token) ?? "";
|
|
23824
23804
|
const res = ensureAuthed(await (opts.reach ?? reach)(`${BACKEND_URL}/api/goals/claim`, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${token}`, "x-paigy-model": "goal-entry-v1" }, body: JSON.stringify(goalId ? { goalId } : {}) }));
|
|
@@ -23930,20 +23910,34 @@ async function contact(input, opts = {}) {
|
|
|
23930
23910
|
const send22 = opts.reach ?? reach;
|
|
23931
23911
|
const headers = { "content-type": "application/json", authorization: `Bearer ${authToken(opts.token) ?? ""}`, "x-paigy-model": "goal-entry-v1" };
|
|
23932
23912
|
let deliveryId;
|
|
23933
|
-
|
|
23934
|
-
|
|
23935
|
-
|
|
23936
|
-
|
|
23937
|
-
const
|
|
23913
|
+
let deliveries = [];
|
|
23914
|
+
if ("deliveryId" in parsed) {
|
|
23915
|
+
deliveryId = parsed.deliveryId;
|
|
23916
|
+
} else {
|
|
23917
|
+
const reqAsks = parsed.asks.map((a) => ({
|
|
23918
|
+
id: a.id,
|
|
23919
|
+
parentId: a.parentId,
|
|
23920
|
+
repo: a.repo,
|
|
23921
|
+
ask: a.ask,
|
|
23922
|
+
options: a.options ?? []
|
|
23923
|
+
}));
|
|
23924
|
+
const res = ensureAuthed(await send22(`${BACKEND_URL}/api/goals/contact`, {
|
|
23938
23925
|
method: "POST",
|
|
23939
23926
|
headers,
|
|
23940
23927
|
signal: opts.signal,
|
|
23941
|
-
body: JSON.stringify({
|
|
23928
|
+
body: JSON.stringify({
|
|
23929
|
+
operationId: opts.operationId ?? randomUUID3(),
|
|
23930
|
+
asks: reqAsks,
|
|
23931
|
+
waiting: parsed.waiting,
|
|
23932
|
+
channel: parsed.channel === "call" ? "call" : "message"
|
|
23933
|
+
})
|
|
23942
23934
|
}));
|
|
23943
|
-
if (!res.ok) await fail("
|
|
23935
|
+
if (!res.ok) await fail("batch contact", res);
|
|
23944
23936
|
const receipt = await res.json();
|
|
23945
|
-
|
|
23946
|
-
if (
|
|
23937
|
+
deliveries = receipt.deliveries ?? [];
|
|
23938
|
+
if (deliveries.length === 0) throw new Error("Goal contact returned no Delivery identities");
|
|
23939
|
+
deliveryId = deliveries[0]?.deliveryId ?? "";
|
|
23940
|
+
if (!deliveryId) throw new Error("Goal contact returned no valid Delivery identity");
|
|
23947
23941
|
}
|
|
23948
23942
|
const read = async (signal2) => {
|
|
23949
23943
|
const res = ensureAuthed(await send22(`${BACKEND_URL}/api/deliveries/${encodeURIComponent(deliveryId)}`, { headers, signal: signal2 }));
|
|
@@ -24068,7 +24062,7 @@ async function subscribeWake(onNudge, opts = {}) {
|
|
|
24068
24062
|
}
|
|
24069
24063
|
};
|
|
24070
24064
|
}
|
|
24071
|
-
var import_undici, require2,
|
|
24065
|
+
var import_undici, require2, BACKEND_URL, NETWORK_MSG, PROXY_ENV, agent, INSTANCE_ID, WORKSPACE_ID, envSession, lineage, ignoreOverride, defaultOptions, getDefaultOptions, getRefs, getRelativePath, parseCatchDef, integerDateParser, isJsonSchema7AllOfType, emojiRegex2, zodPatterns, ALPHA_NUMERIC, primitiveMappings, asAnyOf, parseOptionalDef, parsePipelineDef, parseReadonlyDef, selectParser, get$ref, addMeta, zodToJsonSchema, OPTIONS_MIN, OPTIONS_MAX, AskInputSchema, StartContactSchema, ContactSchema, CONTACT_SCHEMA, CONTACT_DESCRIPTION, CreateGoalSchema, CreateGoalToolSchema, CREATE_GOAL_DESCRIPTION, UpdateGoalSchema, UpdateGoalToolSchema, ClaimGoalSchema, GetGoalSchema, GET_GOAL_DESCRIPTION, UPDATE_GOAL_DESCRIPTION, CLAIM_GOAL_DESCRIPTION, CHECK_REPLIES_DESCRIPTION, CheckRepliesSchema, GetThreadSchema, GET_THREAD_DESCRIPTION, SearchThreadsSchema, SEARCH_THREADS_DESCRIPTION, AGENT_TOOLS, AGENT_TOOL_NAMES, LIVE_MS, ContextSchema, ParticipantSchema, TransformSchema, OptionSchema, VisualSchema, NotifyLevelSchema, SelectShapeSchema, ReceiptEventSchema, AttentionSchema, NotifyRequestFields, NotifyRequestSchema, NotifyStatusSchema, AgentStateSchema, TurnSchema, UserAnswerSchema, IntentSchema, RideAlongSchema, AwaitItemSchema, VoiceKeySchema, AgendaTurnSchema, CLAIM_STALE_MS, InboxItemSchema, APNS_TOKEN_RE, PushTokenSchema, MissedCallSchema, BrokerTuningSchema, UserSettingsSchema, HistoryItemSchema, ACTIVITY_LINES, ACTIVITY_LINE_MAX, AgentActivitySchema, ConnectionSummarySchema, LedgerItemSchema, AgentLedgerSchema, ReassignResultSchema, MoveRingSchema, MoveSchema, QueueQuestionSchema, QueueItemSchema, NoteSourceSchema, NoteStatusSchema, NoteRepeatSchema, DecisionSchema, NoteSchema, TriageItemSchema, TriageAssignmentSchema, TriageStatusSchema, SubmitTriageSchema, TriageProposalSchema, AcceptTriageSchema, AcceptTriageResultSchema, DeliveryModeSchema, WAKE_EVENT, wakeChannel, RegisterDeliverySchema, OAuthStartSchema, DeliveryConfigSchema, WakeNudgeSchema, PairingStatusSchema, DeviceCodeSchema, DeviceInfoSchema, DeviceTokenSchema, SupportRequestSchema, NotificationFeedbackKindSchema, TOKEN_PATH, KEY_PATH, sleep, UnpairedError, ApiError, AWAIT_WINDOW_MS, tokenOverride, authToken, HEARTBEAT_MS, RETRY_MS, JOIN, lines;
|
|
24072
24066
|
var init_dist = __esm({
|
|
24073
24067
|
"../../packages/sdk/dist/index.js"() {
|
|
24074
24068
|
"use strict";
|
|
@@ -24080,2260 +24074,6 @@ var init_dist = __esm({
|
|
|
24080
24074
|
init_zod();
|
|
24081
24075
|
import_undici = __toESM(require_undici(), 1);
|
|
24082
24076
|
require2 = __sdkCreateRequire(import.meta.url);
|
|
24083
|
-
__create2 = Object.create;
|
|
24084
|
-
__defProp2 = Object.defineProperty;
|
|
24085
|
-
__getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
24086
|
-
__getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
24087
|
-
__getProtoOf2 = Object.getPrototypeOf;
|
|
24088
|
-
__hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
24089
|
-
__require2 = /* @__PURE__ */ ((x) => typeof require2 !== "undefined" ? require2 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
24090
|
-
get: (a, b) => (typeof require2 !== "undefined" ? require2 : a)[b]
|
|
24091
|
-
}) : x)(function(x) {
|
|
24092
|
-
if (typeof require2 !== "undefined") return require2.apply(this, arguments);
|
|
24093
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
24094
|
-
});
|
|
24095
|
-
__commonJS2 = (cb, mod) => function __require22() {
|
|
24096
|
-
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24097
|
-
};
|
|
24098
|
-
__copyProps2 = (to, from, except, desc) => {
|
|
24099
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
24100
|
-
for (let key of __getOwnPropNames2(from))
|
|
24101
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
24102
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
24103
|
-
}
|
|
24104
|
-
return to;
|
|
24105
|
-
};
|
|
24106
|
-
__toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
|
|
24107
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24108
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24109
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24110
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24111
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
|
|
24112
|
-
mod
|
|
24113
|
-
));
|
|
24114
|
-
require_nacl_fast = __commonJS2({
|
|
24115
|
-
"../../node_modules/.pnpm/tweetnacl@1.0.3/node_modules/tweetnacl/nacl-fast.js"(exports, module) {
|
|
24116
|
-
"use strict";
|
|
24117
|
-
(function(nacl6) {
|
|
24118
|
-
"use strict";
|
|
24119
|
-
var gf = function(init) {
|
|
24120
|
-
var i, r = new Float64Array(16);
|
|
24121
|
-
if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
|
|
24122
|
-
return r;
|
|
24123
|
-
};
|
|
24124
|
-
var randombytes = function() {
|
|
24125
|
-
throw new Error("no PRNG");
|
|
24126
|
-
};
|
|
24127
|
-
var _0 = new Uint8Array(16);
|
|
24128
|
-
var _9 = new Uint8Array(32);
|
|
24129
|
-
_9[0] = 9;
|
|
24130
|
-
var gf0 = gf(), gf1 = gf([1]), _121665 = gf([56129, 1]), D = gf([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), D2 = gf([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), X = gf([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), Y = gf([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), I = gf([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]);
|
|
24131
|
-
function ts64(x, i, h, l) {
|
|
24132
|
-
x[i] = h >> 24 & 255;
|
|
24133
|
-
x[i + 1] = h >> 16 & 255;
|
|
24134
|
-
x[i + 2] = h >> 8 & 255;
|
|
24135
|
-
x[i + 3] = h & 255;
|
|
24136
|
-
x[i + 4] = l >> 24 & 255;
|
|
24137
|
-
x[i + 5] = l >> 16 & 255;
|
|
24138
|
-
x[i + 6] = l >> 8 & 255;
|
|
24139
|
-
x[i + 7] = l & 255;
|
|
24140
|
-
}
|
|
24141
|
-
function vn(x, xi, y, yi, n) {
|
|
24142
|
-
var i, d = 0;
|
|
24143
|
-
for (i = 0; i < n; i++) d |= x[xi + i] ^ y[yi + i];
|
|
24144
|
-
return (1 & d - 1 >>> 8) - 1;
|
|
24145
|
-
}
|
|
24146
|
-
function crypto_verify_16(x, xi, y, yi) {
|
|
24147
|
-
return vn(x, xi, y, yi, 16);
|
|
24148
|
-
}
|
|
24149
|
-
function crypto_verify_32(x, xi, y, yi) {
|
|
24150
|
-
return vn(x, xi, y, yi, 32);
|
|
24151
|
-
}
|
|
24152
|
-
function core_salsa20(o, p, k, c) {
|
|
24153
|
-
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
24154
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
|
|
24155
|
-
for (var i = 0; i < 20; i += 2) {
|
|
24156
|
-
u = x0 + x12 | 0;
|
|
24157
|
-
x4 ^= u << 7 | u >>> 32 - 7;
|
|
24158
|
-
u = x4 + x0 | 0;
|
|
24159
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
24160
|
-
u = x8 + x4 | 0;
|
|
24161
|
-
x12 ^= u << 13 | u >>> 32 - 13;
|
|
24162
|
-
u = x12 + x8 | 0;
|
|
24163
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
24164
|
-
u = x5 + x1 | 0;
|
|
24165
|
-
x9 ^= u << 7 | u >>> 32 - 7;
|
|
24166
|
-
u = x9 + x5 | 0;
|
|
24167
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
24168
|
-
u = x13 + x9 | 0;
|
|
24169
|
-
x1 ^= u << 13 | u >>> 32 - 13;
|
|
24170
|
-
u = x1 + x13 | 0;
|
|
24171
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
24172
|
-
u = x10 + x6 | 0;
|
|
24173
|
-
x14 ^= u << 7 | u >>> 32 - 7;
|
|
24174
|
-
u = x14 + x10 | 0;
|
|
24175
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
24176
|
-
u = x2 + x14 | 0;
|
|
24177
|
-
x6 ^= u << 13 | u >>> 32 - 13;
|
|
24178
|
-
u = x6 + x2 | 0;
|
|
24179
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
24180
|
-
u = x15 + x11 | 0;
|
|
24181
|
-
x3 ^= u << 7 | u >>> 32 - 7;
|
|
24182
|
-
u = x3 + x15 | 0;
|
|
24183
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
24184
|
-
u = x7 + x3 | 0;
|
|
24185
|
-
x11 ^= u << 13 | u >>> 32 - 13;
|
|
24186
|
-
u = x11 + x7 | 0;
|
|
24187
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
24188
|
-
u = x0 + x3 | 0;
|
|
24189
|
-
x1 ^= u << 7 | u >>> 32 - 7;
|
|
24190
|
-
u = x1 + x0 | 0;
|
|
24191
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
24192
|
-
u = x2 + x1 | 0;
|
|
24193
|
-
x3 ^= u << 13 | u >>> 32 - 13;
|
|
24194
|
-
u = x3 + x2 | 0;
|
|
24195
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
24196
|
-
u = x5 + x4 | 0;
|
|
24197
|
-
x6 ^= u << 7 | u >>> 32 - 7;
|
|
24198
|
-
u = x6 + x5 | 0;
|
|
24199
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
24200
|
-
u = x7 + x6 | 0;
|
|
24201
|
-
x4 ^= u << 13 | u >>> 32 - 13;
|
|
24202
|
-
u = x4 + x7 | 0;
|
|
24203
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
24204
|
-
u = x10 + x9 | 0;
|
|
24205
|
-
x11 ^= u << 7 | u >>> 32 - 7;
|
|
24206
|
-
u = x11 + x10 | 0;
|
|
24207
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
24208
|
-
u = x8 + x11 | 0;
|
|
24209
|
-
x9 ^= u << 13 | u >>> 32 - 13;
|
|
24210
|
-
u = x9 + x8 | 0;
|
|
24211
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
24212
|
-
u = x15 + x14 | 0;
|
|
24213
|
-
x12 ^= u << 7 | u >>> 32 - 7;
|
|
24214
|
-
u = x12 + x15 | 0;
|
|
24215
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
24216
|
-
u = x13 + x12 | 0;
|
|
24217
|
-
x14 ^= u << 13 | u >>> 32 - 13;
|
|
24218
|
-
u = x14 + x13 | 0;
|
|
24219
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
24220
|
-
}
|
|
24221
|
-
x0 = x0 + j0 | 0;
|
|
24222
|
-
x1 = x1 + j1 | 0;
|
|
24223
|
-
x2 = x2 + j2 | 0;
|
|
24224
|
-
x3 = x3 + j3 | 0;
|
|
24225
|
-
x4 = x4 + j4 | 0;
|
|
24226
|
-
x5 = x5 + j5 | 0;
|
|
24227
|
-
x6 = x6 + j6 | 0;
|
|
24228
|
-
x7 = x7 + j7 | 0;
|
|
24229
|
-
x8 = x8 + j8 | 0;
|
|
24230
|
-
x9 = x9 + j9 | 0;
|
|
24231
|
-
x10 = x10 + j10 | 0;
|
|
24232
|
-
x11 = x11 + j11 | 0;
|
|
24233
|
-
x12 = x12 + j12 | 0;
|
|
24234
|
-
x13 = x13 + j13 | 0;
|
|
24235
|
-
x14 = x14 + j14 | 0;
|
|
24236
|
-
x15 = x15 + j15 | 0;
|
|
24237
|
-
o[0] = x0 >>> 0 & 255;
|
|
24238
|
-
o[1] = x0 >>> 8 & 255;
|
|
24239
|
-
o[2] = x0 >>> 16 & 255;
|
|
24240
|
-
o[3] = x0 >>> 24 & 255;
|
|
24241
|
-
o[4] = x1 >>> 0 & 255;
|
|
24242
|
-
o[5] = x1 >>> 8 & 255;
|
|
24243
|
-
o[6] = x1 >>> 16 & 255;
|
|
24244
|
-
o[7] = x1 >>> 24 & 255;
|
|
24245
|
-
o[8] = x2 >>> 0 & 255;
|
|
24246
|
-
o[9] = x2 >>> 8 & 255;
|
|
24247
|
-
o[10] = x2 >>> 16 & 255;
|
|
24248
|
-
o[11] = x2 >>> 24 & 255;
|
|
24249
|
-
o[12] = x3 >>> 0 & 255;
|
|
24250
|
-
o[13] = x3 >>> 8 & 255;
|
|
24251
|
-
o[14] = x3 >>> 16 & 255;
|
|
24252
|
-
o[15] = x3 >>> 24 & 255;
|
|
24253
|
-
o[16] = x4 >>> 0 & 255;
|
|
24254
|
-
o[17] = x4 >>> 8 & 255;
|
|
24255
|
-
o[18] = x4 >>> 16 & 255;
|
|
24256
|
-
o[19] = x4 >>> 24 & 255;
|
|
24257
|
-
o[20] = x5 >>> 0 & 255;
|
|
24258
|
-
o[21] = x5 >>> 8 & 255;
|
|
24259
|
-
o[22] = x5 >>> 16 & 255;
|
|
24260
|
-
o[23] = x5 >>> 24 & 255;
|
|
24261
|
-
o[24] = x6 >>> 0 & 255;
|
|
24262
|
-
o[25] = x6 >>> 8 & 255;
|
|
24263
|
-
o[26] = x6 >>> 16 & 255;
|
|
24264
|
-
o[27] = x6 >>> 24 & 255;
|
|
24265
|
-
o[28] = x7 >>> 0 & 255;
|
|
24266
|
-
o[29] = x7 >>> 8 & 255;
|
|
24267
|
-
o[30] = x7 >>> 16 & 255;
|
|
24268
|
-
o[31] = x7 >>> 24 & 255;
|
|
24269
|
-
o[32] = x8 >>> 0 & 255;
|
|
24270
|
-
o[33] = x8 >>> 8 & 255;
|
|
24271
|
-
o[34] = x8 >>> 16 & 255;
|
|
24272
|
-
o[35] = x8 >>> 24 & 255;
|
|
24273
|
-
o[36] = x9 >>> 0 & 255;
|
|
24274
|
-
o[37] = x9 >>> 8 & 255;
|
|
24275
|
-
o[38] = x9 >>> 16 & 255;
|
|
24276
|
-
o[39] = x9 >>> 24 & 255;
|
|
24277
|
-
o[40] = x10 >>> 0 & 255;
|
|
24278
|
-
o[41] = x10 >>> 8 & 255;
|
|
24279
|
-
o[42] = x10 >>> 16 & 255;
|
|
24280
|
-
o[43] = x10 >>> 24 & 255;
|
|
24281
|
-
o[44] = x11 >>> 0 & 255;
|
|
24282
|
-
o[45] = x11 >>> 8 & 255;
|
|
24283
|
-
o[46] = x11 >>> 16 & 255;
|
|
24284
|
-
o[47] = x11 >>> 24 & 255;
|
|
24285
|
-
o[48] = x12 >>> 0 & 255;
|
|
24286
|
-
o[49] = x12 >>> 8 & 255;
|
|
24287
|
-
o[50] = x12 >>> 16 & 255;
|
|
24288
|
-
o[51] = x12 >>> 24 & 255;
|
|
24289
|
-
o[52] = x13 >>> 0 & 255;
|
|
24290
|
-
o[53] = x13 >>> 8 & 255;
|
|
24291
|
-
o[54] = x13 >>> 16 & 255;
|
|
24292
|
-
o[55] = x13 >>> 24 & 255;
|
|
24293
|
-
o[56] = x14 >>> 0 & 255;
|
|
24294
|
-
o[57] = x14 >>> 8 & 255;
|
|
24295
|
-
o[58] = x14 >>> 16 & 255;
|
|
24296
|
-
o[59] = x14 >>> 24 & 255;
|
|
24297
|
-
o[60] = x15 >>> 0 & 255;
|
|
24298
|
-
o[61] = x15 >>> 8 & 255;
|
|
24299
|
-
o[62] = x15 >>> 16 & 255;
|
|
24300
|
-
o[63] = x15 >>> 24 & 255;
|
|
24301
|
-
}
|
|
24302
|
-
function core_hsalsa20(o, p, k, c) {
|
|
24303
|
-
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k[0] & 255 | (k[1] & 255) << 8 | (k[2] & 255) << 16 | (k[3] & 255) << 24, j2 = k[4] & 255 | (k[5] & 255) << 8 | (k[6] & 255) << 16 | (k[7] & 255) << 24, j3 = k[8] & 255 | (k[9] & 255) << 8 | (k[10] & 255) << 16 | (k[11] & 255) << 24, j4 = k[12] & 255 | (k[13] & 255) << 8 | (k[14] & 255) << 16 | (k[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p[0] & 255 | (p[1] & 255) << 8 | (p[2] & 255) << 16 | (p[3] & 255) << 24, j7 = p[4] & 255 | (p[5] & 255) << 8 | (p[6] & 255) << 16 | (p[7] & 255) << 24, j8 = p[8] & 255 | (p[9] & 255) << 8 | (p[10] & 255) << 16 | (p[11] & 255) << 24, j9 = p[12] & 255 | (p[13] & 255) << 8 | (p[14] & 255) << 16 | (p[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k[16] & 255 | (k[17] & 255) << 8 | (k[18] & 255) << 16 | (k[19] & 255) << 24, j12 = k[20] & 255 | (k[21] & 255) << 8 | (k[22] & 255) << 16 | (k[23] & 255) << 24, j13 = k[24] & 255 | (k[25] & 255) << 8 | (k[26] & 255) << 16 | (k[27] & 255) << 24, j14 = k[28] & 255 | (k[29] & 255) << 8 | (k[30] & 255) << 16 | (k[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
24304
|
-
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u;
|
|
24305
|
-
for (var i = 0; i < 20; i += 2) {
|
|
24306
|
-
u = x0 + x12 | 0;
|
|
24307
|
-
x4 ^= u << 7 | u >>> 32 - 7;
|
|
24308
|
-
u = x4 + x0 | 0;
|
|
24309
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
24310
|
-
u = x8 + x4 | 0;
|
|
24311
|
-
x12 ^= u << 13 | u >>> 32 - 13;
|
|
24312
|
-
u = x12 + x8 | 0;
|
|
24313
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
24314
|
-
u = x5 + x1 | 0;
|
|
24315
|
-
x9 ^= u << 7 | u >>> 32 - 7;
|
|
24316
|
-
u = x9 + x5 | 0;
|
|
24317
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
24318
|
-
u = x13 + x9 | 0;
|
|
24319
|
-
x1 ^= u << 13 | u >>> 32 - 13;
|
|
24320
|
-
u = x1 + x13 | 0;
|
|
24321
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
24322
|
-
u = x10 + x6 | 0;
|
|
24323
|
-
x14 ^= u << 7 | u >>> 32 - 7;
|
|
24324
|
-
u = x14 + x10 | 0;
|
|
24325
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
24326
|
-
u = x2 + x14 | 0;
|
|
24327
|
-
x6 ^= u << 13 | u >>> 32 - 13;
|
|
24328
|
-
u = x6 + x2 | 0;
|
|
24329
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
24330
|
-
u = x15 + x11 | 0;
|
|
24331
|
-
x3 ^= u << 7 | u >>> 32 - 7;
|
|
24332
|
-
u = x3 + x15 | 0;
|
|
24333
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
24334
|
-
u = x7 + x3 | 0;
|
|
24335
|
-
x11 ^= u << 13 | u >>> 32 - 13;
|
|
24336
|
-
u = x11 + x7 | 0;
|
|
24337
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
24338
|
-
u = x0 + x3 | 0;
|
|
24339
|
-
x1 ^= u << 7 | u >>> 32 - 7;
|
|
24340
|
-
u = x1 + x0 | 0;
|
|
24341
|
-
x2 ^= u << 9 | u >>> 32 - 9;
|
|
24342
|
-
u = x2 + x1 | 0;
|
|
24343
|
-
x3 ^= u << 13 | u >>> 32 - 13;
|
|
24344
|
-
u = x3 + x2 | 0;
|
|
24345
|
-
x0 ^= u << 18 | u >>> 32 - 18;
|
|
24346
|
-
u = x5 + x4 | 0;
|
|
24347
|
-
x6 ^= u << 7 | u >>> 32 - 7;
|
|
24348
|
-
u = x6 + x5 | 0;
|
|
24349
|
-
x7 ^= u << 9 | u >>> 32 - 9;
|
|
24350
|
-
u = x7 + x6 | 0;
|
|
24351
|
-
x4 ^= u << 13 | u >>> 32 - 13;
|
|
24352
|
-
u = x4 + x7 | 0;
|
|
24353
|
-
x5 ^= u << 18 | u >>> 32 - 18;
|
|
24354
|
-
u = x10 + x9 | 0;
|
|
24355
|
-
x11 ^= u << 7 | u >>> 32 - 7;
|
|
24356
|
-
u = x11 + x10 | 0;
|
|
24357
|
-
x8 ^= u << 9 | u >>> 32 - 9;
|
|
24358
|
-
u = x8 + x11 | 0;
|
|
24359
|
-
x9 ^= u << 13 | u >>> 32 - 13;
|
|
24360
|
-
u = x9 + x8 | 0;
|
|
24361
|
-
x10 ^= u << 18 | u >>> 32 - 18;
|
|
24362
|
-
u = x15 + x14 | 0;
|
|
24363
|
-
x12 ^= u << 7 | u >>> 32 - 7;
|
|
24364
|
-
u = x12 + x15 | 0;
|
|
24365
|
-
x13 ^= u << 9 | u >>> 32 - 9;
|
|
24366
|
-
u = x13 + x12 | 0;
|
|
24367
|
-
x14 ^= u << 13 | u >>> 32 - 13;
|
|
24368
|
-
u = x14 + x13 | 0;
|
|
24369
|
-
x15 ^= u << 18 | u >>> 32 - 18;
|
|
24370
|
-
}
|
|
24371
|
-
o[0] = x0 >>> 0 & 255;
|
|
24372
|
-
o[1] = x0 >>> 8 & 255;
|
|
24373
|
-
o[2] = x0 >>> 16 & 255;
|
|
24374
|
-
o[3] = x0 >>> 24 & 255;
|
|
24375
|
-
o[4] = x5 >>> 0 & 255;
|
|
24376
|
-
o[5] = x5 >>> 8 & 255;
|
|
24377
|
-
o[6] = x5 >>> 16 & 255;
|
|
24378
|
-
o[7] = x5 >>> 24 & 255;
|
|
24379
|
-
o[8] = x10 >>> 0 & 255;
|
|
24380
|
-
o[9] = x10 >>> 8 & 255;
|
|
24381
|
-
o[10] = x10 >>> 16 & 255;
|
|
24382
|
-
o[11] = x10 >>> 24 & 255;
|
|
24383
|
-
o[12] = x15 >>> 0 & 255;
|
|
24384
|
-
o[13] = x15 >>> 8 & 255;
|
|
24385
|
-
o[14] = x15 >>> 16 & 255;
|
|
24386
|
-
o[15] = x15 >>> 24 & 255;
|
|
24387
|
-
o[16] = x6 >>> 0 & 255;
|
|
24388
|
-
o[17] = x6 >>> 8 & 255;
|
|
24389
|
-
o[18] = x6 >>> 16 & 255;
|
|
24390
|
-
o[19] = x6 >>> 24 & 255;
|
|
24391
|
-
o[20] = x7 >>> 0 & 255;
|
|
24392
|
-
o[21] = x7 >>> 8 & 255;
|
|
24393
|
-
o[22] = x7 >>> 16 & 255;
|
|
24394
|
-
o[23] = x7 >>> 24 & 255;
|
|
24395
|
-
o[24] = x8 >>> 0 & 255;
|
|
24396
|
-
o[25] = x8 >>> 8 & 255;
|
|
24397
|
-
o[26] = x8 >>> 16 & 255;
|
|
24398
|
-
o[27] = x8 >>> 24 & 255;
|
|
24399
|
-
o[28] = x9 >>> 0 & 255;
|
|
24400
|
-
o[29] = x9 >>> 8 & 255;
|
|
24401
|
-
o[30] = x9 >>> 16 & 255;
|
|
24402
|
-
o[31] = x9 >>> 24 & 255;
|
|
24403
|
-
}
|
|
24404
|
-
function crypto_core_salsa20(out, inp, k, c) {
|
|
24405
|
-
core_salsa20(out, inp, k, c);
|
|
24406
|
-
}
|
|
24407
|
-
function crypto_core_hsalsa20(out, inp, k, c) {
|
|
24408
|
-
core_hsalsa20(out, inp, k, c);
|
|
24409
|
-
}
|
|
24410
|
-
var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
|
|
24411
|
-
function crypto_stream_salsa20_xor(c, cpos, m, mpos, b, n, k) {
|
|
24412
|
-
var z4 = new Uint8Array(16), x = new Uint8Array(64);
|
|
24413
|
-
var u, i;
|
|
24414
|
-
for (i = 0; i < 16; i++) z4[i] = 0;
|
|
24415
|
-
for (i = 0; i < 8; i++) z4[i] = n[i];
|
|
24416
|
-
while (b >= 64) {
|
|
24417
|
-
crypto_core_salsa20(x, z4, k, sigma);
|
|
24418
|
-
for (i = 0; i < 64; i++) c[cpos + i] = m[mpos + i] ^ x[i];
|
|
24419
|
-
u = 1;
|
|
24420
|
-
for (i = 8; i < 16; i++) {
|
|
24421
|
-
u = u + (z4[i] & 255) | 0;
|
|
24422
|
-
z4[i] = u & 255;
|
|
24423
|
-
u >>>= 8;
|
|
24424
|
-
}
|
|
24425
|
-
b -= 64;
|
|
24426
|
-
cpos += 64;
|
|
24427
|
-
mpos += 64;
|
|
24428
|
-
}
|
|
24429
|
-
if (b > 0) {
|
|
24430
|
-
crypto_core_salsa20(x, z4, k, sigma);
|
|
24431
|
-
for (i = 0; i < b; i++) c[cpos + i] = m[mpos + i] ^ x[i];
|
|
24432
|
-
}
|
|
24433
|
-
return 0;
|
|
24434
|
-
}
|
|
24435
|
-
function crypto_stream_salsa20(c, cpos, b, n, k) {
|
|
24436
|
-
var z4 = new Uint8Array(16), x = new Uint8Array(64);
|
|
24437
|
-
var u, i;
|
|
24438
|
-
for (i = 0; i < 16; i++) z4[i] = 0;
|
|
24439
|
-
for (i = 0; i < 8; i++) z4[i] = n[i];
|
|
24440
|
-
while (b >= 64) {
|
|
24441
|
-
crypto_core_salsa20(x, z4, k, sigma);
|
|
24442
|
-
for (i = 0; i < 64; i++) c[cpos + i] = x[i];
|
|
24443
|
-
u = 1;
|
|
24444
|
-
for (i = 8; i < 16; i++) {
|
|
24445
|
-
u = u + (z4[i] & 255) | 0;
|
|
24446
|
-
z4[i] = u & 255;
|
|
24447
|
-
u >>>= 8;
|
|
24448
|
-
}
|
|
24449
|
-
b -= 64;
|
|
24450
|
-
cpos += 64;
|
|
24451
|
-
}
|
|
24452
|
-
if (b > 0) {
|
|
24453
|
-
crypto_core_salsa20(x, z4, k, sigma);
|
|
24454
|
-
for (i = 0; i < b; i++) c[cpos + i] = x[i];
|
|
24455
|
-
}
|
|
24456
|
-
return 0;
|
|
24457
|
-
}
|
|
24458
|
-
function crypto_stream(c, cpos, d, n, k) {
|
|
24459
|
-
var s = new Uint8Array(32);
|
|
24460
|
-
crypto_core_hsalsa20(s, n, k, sigma);
|
|
24461
|
-
var sn = new Uint8Array(8);
|
|
24462
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
|
|
24463
|
-
return crypto_stream_salsa20(c, cpos, d, sn, s);
|
|
24464
|
-
}
|
|
24465
|
-
function crypto_stream_xor(c, cpos, m, mpos, d, n, k) {
|
|
24466
|
-
var s = new Uint8Array(32);
|
|
24467
|
-
crypto_core_hsalsa20(s, n, k, sigma);
|
|
24468
|
-
var sn = new Uint8Array(8);
|
|
24469
|
-
for (var i = 0; i < 8; i++) sn[i] = n[i + 16];
|
|
24470
|
-
return crypto_stream_salsa20_xor(c, cpos, m, mpos, d, sn, s);
|
|
24471
|
-
}
|
|
24472
|
-
var poly1305 = function(key) {
|
|
24473
|
-
this.buffer = new Uint8Array(16);
|
|
24474
|
-
this.r = new Uint16Array(10);
|
|
24475
|
-
this.h = new Uint16Array(10);
|
|
24476
|
-
this.pad = new Uint16Array(8);
|
|
24477
|
-
this.leftover = 0;
|
|
24478
|
-
this.fin = 0;
|
|
24479
|
-
var t0, t1, t2, t3, t4, t5, t6, t7;
|
|
24480
|
-
t0 = key[0] & 255 | (key[1] & 255) << 8;
|
|
24481
|
-
this.r[0] = t0 & 8191;
|
|
24482
|
-
t1 = key[2] & 255 | (key[3] & 255) << 8;
|
|
24483
|
-
this.r[1] = (t0 >>> 13 | t1 << 3) & 8191;
|
|
24484
|
-
t2 = key[4] & 255 | (key[5] & 255) << 8;
|
|
24485
|
-
this.r[2] = (t1 >>> 10 | t2 << 6) & 7939;
|
|
24486
|
-
t3 = key[6] & 255 | (key[7] & 255) << 8;
|
|
24487
|
-
this.r[3] = (t2 >>> 7 | t3 << 9) & 8191;
|
|
24488
|
-
t4 = key[8] & 255 | (key[9] & 255) << 8;
|
|
24489
|
-
this.r[4] = (t3 >>> 4 | t4 << 12) & 255;
|
|
24490
|
-
this.r[5] = t4 >>> 1 & 8190;
|
|
24491
|
-
t5 = key[10] & 255 | (key[11] & 255) << 8;
|
|
24492
|
-
this.r[6] = (t4 >>> 14 | t5 << 2) & 8191;
|
|
24493
|
-
t6 = key[12] & 255 | (key[13] & 255) << 8;
|
|
24494
|
-
this.r[7] = (t5 >>> 11 | t6 << 5) & 8065;
|
|
24495
|
-
t7 = key[14] & 255 | (key[15] & 255) << 8;
|
|
24496
|
-
this.r[8] = (t6 >>> 8 | t7 << 8) & 8191;
|
|
24497
|
-
this.r[9] = t7 >>> 5 & 127;
|
|
24498
|
-
this.pad[0] = key[16] & 255 | (key[17] & 255) << 8;
|
|
24499
|
-
this.pad[1] = key[18] & 255 | (key[19] & 255) << 8;
|
|
24500
|
-
this.pad[2] = key[20] & 255 | (key[21] & 255) << 8;
|
|
24501
|
-
this.pad[3] = key[22] & 255 | (key[23] & 255) << 8;
|
|
24502
|
-
this.pad[4] = key[24] & 255 | (key[25] & 255) << 8;
|
|
24503
|
-
this.pad[5] = key[26] & 255 | (key[27] & 255) << 8;
|
|
24504
|
-
this.pad[6] = key[28] & 255 | (key[29] & 255) << 8;
|
|
24505
|
-
this.pad[7] = key[30] & 255 | (key[31] & 255) << 8;
|
|
24506
|
-
};
|
|
24507
|
-
poly1305.prototype.blocks = function(m, mpos, bytes) {
|
|
24508
|
-
var hibit = this.fin ? 0 : 1 << 11;
|
|
24509
|
-
var t0, t1, t2, t3, t4, t5, t6, t7, c;
|
|
24510
|
-
var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
|
|
24511
|
-
var h0 = this.h[0], h1 = this.h[1], h2 = this.h[2], h3 = this.h[3], h4 = this.h[4], h5 = this.h[5], h6 = this.h[6], h7 = this.h[7], h8 = this.h[8], h9 = this.h[9];
|
|
24512
|
-
var r0 = this.r[0], r1 = this.r[1], r2 = this.r[2], r3 = this.r[3], r4 = this.r[4], r5 = this.r[5], r6 = this.r[6], r7 = this.r[7], r8 = this.r[8], r9 = this.r[9];
|
|
24513
|
-
while (bytes >= 16) {
|
|
24514
|
-
t0 = m[mpos + 0] & 255 | (m[mpos + 1] & 255) << 8;
|
|
24515
|
-
h0 += t0 & 8191;
|
|
24516
|
-
t1 = m[mpos + 2] & 255 | (m[mpos + 3] & 255) << 8;
|
|
24517
|
-
h1 += (t0 >>> 13 | t1 << 3) & 8191;
|
|
24518
|
-
t2 = m[mpos + 4] & 255 | (m[mpos + 5] & 255) << 8;
|
|
24519
|
-
h2 += (t1 >>> 10 | t2 << 6) & 8191;
|
|
24520
|
-
t3 = m[mpos + 6] & 255 | (m[mpos + 7] & 255) << 8;
|
|
24521
|
-
h3 += (t2 >>> 7 | t3 << 9) & 8191;
|
|
24522
|
-
t4 = m[mpos + 8] & 255 | (m[mpos + 9] & 255) << 8;
|
|
24523
|
-
h4 += (t3 >>> 4 | t4 << 12) & 8191;
|
|
24524
|
-
h5 += t4 >>> 1 & 8191;
|
|
24525
|
-
t5 = m[mpos + 10] & 255 | (m[mpos + 11] & 255) << 8;
|
|
24526
|
-
h6 += (t4 >>> 14 | t5 << 2) & 8191;
|
|
24527
|
-
t6 = m[mpos + 12] & 255 | (m[mpos + 13] & 255) << 8;
|
|
24528
|
-
h7 += (t5 >>> 11 | t6 << 5) & 8191;
|
|
24529
|
-
t7 = m[mpos + 14] & 255 | (m[mpos + 15] & 255) << 8;
|
|
24530
|
-
h8 += (t6 >>> 8 | t7 << 8) & 8191;
|
|
24531
|
-
h9 += t7 >>> 5 | hibit;
|
|
24532
|
-
c = 0;
|
|
24533
|
-
d0 = c;
|
|
24534
|
-
d0 += h0 * r0;
|
|
24535
|
-
d0 += h1 * (5 * r9);
|
|
24536
|
-
d0 += h2 * (5 * r8);
|
|
24537
|
-
d0 += h3 * (5 * r7);
|
|
24538
|
-
d0 += h4 * (5 * r6);
|
|
24539
|
-
c = d0 >>> 13;
|
|
24540
|
-
d0 &= 8191;
|
|
24541
|
-
d0 += h5 * (5 * r5);
|
|
24542
|
-
d0 += h6 * (5 * r4);
|
|
24543
|
-
d0 += h7 * (5 * r3);
|
|
24544
|
-
d0 += h8 * (5 * r2);
|
|
24545
|
-
d0 += h9 * (5 * r1);
|
|
24546
|
-
c += d0 >>> 13;
|
|
24547
|
-
d0 &= 8191;
|
|
24548
|
-
d1 = c;
|
|
24549
|
-
d1 += h0 * r1;
|
|
24550
|
-
d1 += h1 * r0;
|
|
24551
|
-
d1 += h2 * (5 * r9);
|
|
24552
|
-
d1 += h3 * (5 * r8);
|
|
24553
|
-
d1 += h4 * (5 * r7);
|
|
24554
|
-
c = d1 >>> 13;
|
|
24555
|
-
d1 &= 8191;
|
|
24556
|
-
d1 += h5 * (5 * r6);
|
|
24557
|
-
d1 += h6 * (5 * r5);
|
|
24558
|
-
d1 += h7 * (5 * r4);
|
|
24559
|
-
d1 += h8 * (5 * r3);
|
|
24560
|
-
d1 += h9 * (5 * r2);
|
|
24561
|
-
c += d1 >>> 13;
|
|
24562
|
-
d1 &= 8191;
|
|
24563
|
-
d2 = c;
|
|
24564
|
-
d2 += h0 * r2;
|
|
24565
|
-
d2 += h1 * r1;
|
|
24566
|
-
d2 += h2 * r0;
|
|
24567
|
-
d2 += h3 * (5 * r9);
|
|
24568
|
-
d2 += h4 * (5 * r8);
|
|
24569
|
-
c = d2 >>> 13;
|
|
24570
|
-
d2 &= 8191;
|
|
24571
|
-
d2 += h5 * (5 * r7);
|
|
24572
|
-
d2 += h6 * (5 * r6);
|
|
24573
|
-
d2 += h7 * (5 * r5);
|
|
24574
|
-
d2 += h8 * (5 * r4);
|
|
24575
|
-
d2 += h9 * (5 * r3);
|
|
24576
|
-
c += d2 >>> 13;
|
|
24577
|
-
d2 &= 8191;
|
|
24578
|
-
d3 = c;
|
|
24579
|
-
d3 += h0 * r3;
|
|
24580
|
-
d3 += h1 * r2;
|
|
24581
|
-
d3 += h2 * r1;
|
|
24582
|
-
d3 += h3 * r0;
|
|
24583
|
-
d3 += h4 * (5 * r9);
|
|
24584
|
-
c = d3 >>> 13;
|
|
24585
|
-
d3 &= 8191;
|
|
24586
|
-
d3 += h5 * (5 * r8);
|
|
24587
|
-
d3 += h6 * (5 * r7);
|
|
24588
|
-
d3 += h7 * (5 * r6);
|
|
24589
|
-
d3 += h8 * (5 * r5);
|
|
24590
|
-
d3 += h9 * (5 * r4);
|
|
24591
|
-
c += d3 >>> 13;
|
|
24592
|
-
d3 &= 8191;
|
|
24593
|
-
d4 = c;
|
|
24594
|
-
d4 += h0 * r4;
|
|
24595
|
-
d4 += h1 * r3;
|
|
24596
|
-
d4 += h2 * r2;
|
|
24597
|
-
d4 += h3 * r1;
|
|
24598
|
-
d4 += h4 * r0;
|
|
24599
|
-
c = d4 >>> 13;
|
|
24600
|
-
d4 &= 8191;
|
|
24601
|
-
d4 += h5 * (5 * r9);
|
|
24602
|
-
d4 += h6 * (5 * r8);
|
|
24603
|
-
d4 += h7 * (5 * r7);
|
|
24604
|
-
d4 += h8 * (5 * r6);
|
|
24605
|
-
d4 += h9 * (5 * r5);
|
|
24606
|
-
c += d4 >>> 13;
|
|
24607
|
-
d4 &= 8191;
|
|
24608
|
-
d5 = c;
|
|
24609
|
-
d5 += h0 * r5;
|
|
24610
|
-
d5 += h1 * r4;
|
|
24611
|
-
d5 += h2 * r3;
|
|
24612
|
-
d5 += h3 * r2;
|
|
24613
|
-
d5 += h4 * r1;
|
|
24614
|
-
c = d5 >>> 13;
|
|
24615
|
-
d5 &= 8191;
|
|
24616
|
-
d5 += h5 * r0;
|
|
24617
|
-
d5 += h6 * (5 * r9);
|
|
24618
|
-
d5 += h7 * (5 * r8);
|
|
24619
|
-
d5 += h8 * (5 * r7);
|
|
24620
|
-
d5 += h9 * (5 * r6);
|
|
24621
|
-
c += d5 >>> 13;
|
|
24622
|
-
d5 &= 8191;
|
|
24623
|
-
d6 = c;
|
|
24624
|
-
d6 += h0 * r6;
|
|
24625
|
-
d6 += h1 * r5;
|
|
24626
|
-
d6 += h2 * r4;
|
|
24627
|
-
d6 += h3 * r3;
|
|
24628
|
-
d6 += h4 * r2;
|
|
24629
|
-
c = d6 >>> 13;
|
|
24630
|
-
d6 &= 8191;
|
|
24631
|
-
d6 += h5 * r1;
|
|
24632
|
-
d6 += h6 * r0;
|
|
24633
|
-
d6 += h7 * (5 * r9);
|
|
24634
|
-
d6 += h8 * (5 * r8);
|
|
24635
|
-
d6 += h9 * (5 * r7);
|
|
24636
|
-
c += d6 >>> 13;
|
|
24637
|
-
d6 &= 8191;
|
|
24638
|
-
d7 = c;
|
|
24639
|
-
d7 += h0 * r7;
|
|
24640
|
-
d7 += h1 * r6;
|
|
24641
|
-
d7 += h2 * r5;
|
|
24642
|
-
d7 += h3 * r4;
|
|
24643
|
-
d7 += h4 * r3;
|
|
24644
|
-
c = d7 >>> 13;
|
|
24645
|
-
d7 &= 8191;
|
|
24646
|
-
d7 += h5 * r2;
|
|
24647
|
-
d7 += h6 * r1;
|
|
24648
|
-
d7 += h7 * r0;
|
|
24649
|
-
d7 += h8 * (5 * r9);
|
|
24650
|
-
d7 += h9 * (5 * r8);
|
|
24651
|
-
c += d7 >>> 13;
|
|
24652
|
-
d7 &= 8191;
|
|
24653
|
-
d8 = c;
|
|
24654
|
-
d8 += h0 * r8;
|
|
24655
|
-
d8 += h1 * r7;
|
|
24656
|
-
d8 += h2 * r6;
|
|
24657
|
-
d8 += h3 * r5;
|
|
24658
|
-
d8 += h4 * r4;
|
|
24659
|
-
c = d8 >>> 13;
|
|
24660
|
-
d8 &= 8191;
|
|
24661
|
-
d8 += h5 * r3;
|
|
24662
|
-
d8 += h6 * r2;
|
|
24663
|
-
d8 += h7 * r1;
|
|
24664
|
-
d8 += h8 * r0;
|
|
24665
|
-
d8 += h9 * (5 * r9);
|
|
24666
|
-
c += d8 >>> 13;
|
|
24667
|
-
d8 &= 8191;
|
|
24668
|
-
d9 = c;
|
|
24669
|
-
d9 += h0 * r9;
|
|
24670
|
-
d9 += h1 * r8;
|
|
24671
|
-
d9 += h2 * r7;
|
|
24672
|
-
d9 += h3 * r6;
|
|
24673
|
-
d9 += h4 * r5;
|
|
24674
|
-
c = d9 >>> 13;
|
|
24675
|
-
d9 &= 8191;
|
|
24676
|
-
d9 += h5 * r4;
|
|
24677
|
-
d9 += h6 * r3;
|
|
24678
|
-
d9 += h7 * r2;
|
|
24679
|
-
d9 += h8 * r1;
|
|
24680
|
-
d9 += h9 * r0;
|
|
24681
|
-
c += d9 >>> 13;
|
|
24682
|
-
d9 &= 8191;
|
|
24683
|
-
c = (c << 2) + c | 0;
|
|
24684
|
-
c = c + d0 | 0;
|
|
24685
|
-
d0 = c & 8191;
|
|
24686
|
-
c = c >>> 13;
|
|
24687
|
-
d1 += c;
|
|
24688
|
-
h0 = d0;
|
|
24689
|
-
h1 = d1;
|
|
24690
|
-
h2 = d2;
|
|
24691
|
-
h3 = d3;
|
|
24692
|
-
h4 = d4;
|
|
24693
|
-
h5 = d5;
|
|
24694
|
-
h6 = d6;
|
|
24695
|
-
h7 = d7;
|
|
24696
|
-
h8 = d8;
|
|
24697
|
-
h9 = d9;
|
|
24698
|
-
mpos += 16;
|
|
24699
|
-
bytes -= 16;
|
|
24700
|
-
}
|
|
24701
|
-
this.h[0] = h0;
|
|
24702
|
-
this.h[1] = h1;
|
|
24703
|
-
this.h[2] = h2;
|
|
24704
|
-
this.h[3] = h3;
|
|
24705
|
-
this.h[4] = h4;
|
|
24706
|
-
this.h[5] = h5;
|
|
24707
|
-
this.h[6] = h6;
|
|
24708
|
-
this.h[7] = h7;
|
|
24709
|
-
this.h[8] = h8;
|
|
24710
|
-
this.h[9] = h9;
|
|
24711
|
-
};
|
|
24712
|
-
poly1305.prototype.finish = function(mac, macpos) {
|
|
24713
|
-
var g = new Uint16Array(10);
|
|
24714
|
-
var c, mask, f, i;
|
|
24715
|
-
if (this.leftover) {
|
|
24716
|
-
i = this.leftover;
|
|
24717
|
-
this.buffer[i++] = 1;
|
|
24718
|
-
for (; i < 16; i++) this.buffer[i] = 0;
|
|
24719
|
-
this.fin = 1;
|
|
24720
|
-
this.blocks(this.buffer, 0, 16);
|
|
24721
|
-
}
|
|
24722
|
-
c = this.h[1] >>> 13;
|
|
24723
|
-
this.h[1] &= 8191;
|
|
24724
|
-
for (i = 2; i < 10; i++) {
|
|
24725
|
-
this.h[i] += c;
|
|
24726
|
-
c = this.h[i] >>> 13;
|
|
24727
|
-
this.h[i] &= 8191;
|
|
24728
|
-
}
|
|
24729
|
-
this.h[0] += c * 5;
|
|
24730
|
-
c = this.h[0] >>> 13;
|
|
24731
|
-
this.h[0] &= 8191;
|
|
24732
|
-
this.h[1] += c;
|
|
24733
|
-
c = this.h[1] >>> 13;
|
|
24734
|
-
this.h[1] &= 8191;
|
|
24735
|
-
this.h[2] += c;
|
|
24736
|
-
g[0] = this.h[0] + 5;
|
|
24737
|
-
c = g[0] >>> 13;
|
|
24738
|
-
g[0] &= 8191;
|
|
24739
|
-
for (i = 1; i < 10; i++) {
|
|
24740
|
-
g[i] = this.h[i] + c;
|
|
24741
|
-
c = g[i] >>> 13;
|
|
24742
|
-
g[i] &= 8191;
|
|
24743
|
-
}
|
|
24744
|
-
g[9] -= 1 << 13;
|
|
24745
|
-
mask = (c ^ 1) - 1;
|
|
24746
|
-
for (i = 0; i < 10; i++) g[i] &= mask;
|
|
24747
|
-
mask = ~mask;
|
|
24748
|
-
for (i = 0; i < 10; i++) this.h[i] = this.h[i] & mask | g[i];
|
|
24749
|
-
this.h[0] = (this.h[0] | this.h[1] << 13) & 65535;
|
|
24750
|
-
this.h[1] = (this.h[1] >>> 3 | this.h[2] << 10) & 65535;
|
|
24751
|
-
this.h[2] = (this.h[2] >>> 6 | this.h[3] << 7) & 65535;
|
|
24752
|
-
this.h[3] = (this.h[3] >>> 9 | this.h[4] << 4) & 65535;
|
|
24753
|
-
this.h[4] = (this.h[4] >>> 12 | this.h[5] << 1 | this.h[6] << 14) & 65535;
|
|
24754
|
-
this.h[5] = (this.h[6] >>> 2 | this.h[7] << 11) & 65535;
|
|
24755
|
-
this.h[6] = (this.h[7] >>> 5 | this.h[8] << 8) & 65535;
|
|
24756
|
-
this.h[7] = (this.h[8] >>> 8 | this.h[9] << 5) & 65535;
|
|
24757
|
-
f = this.h[0] + this.pad[0];
|
|
24758
|
-
this.h[0] = f & 65535;
|
|
24759
|
-
for (i = 1; i < 8; i++) {
|
|
24760
|
-
f = (this.h[i] + this.pad[i] | 0) + (f >>> 16) | 0;
|
|
24761
|
-
this.h[i] = f & 65535;
|
|
24762
|
-
}
|
|
24763
|
-
mac[macpos + 0] = this.h[0] >>> 0 & 255;
|
|
24764
|
-
mac[macpos + 1] = this.h[0] >>> 8 & 255;
|
|
24765
|
-
mac[macpos + 2] = this.h[1] >>> 0 & 255;
|
|
24766
|
-
mac[macpos + 3] = this.h[1] >>> 8 & 255;
|
|
24767
|
-
mac[macpos + 4] = this.h[2] >>> 0 & 255;
|
|
24768
|
-
mac[macpos + 5] = this.h[2] >>> 8 & 255;
|
|
24769
|
-
mac[macpos + 6] = this.h[3] >>> 0 & 255;
|
|
24770
|
-
mac[macpos + 7] = this.h[3] >>> 8 & 255;
|
|
24771
|
-
mac[macpos + 8] = this.h[4] >>> 0 & 255;
|
|
24772
|
-
mac[macpos + 9] = this.h[4] >>> 8 & 255;
|
|
24773
|
-
mac[macpos + 10] = this.h[5] >>> 0 & 255;
|
|
24774
|
-
mac[macpos + 11] = this.h[5] >>> 8 & 255;
|
|
24775
|
-
mac[macpos + 12] = this.h[6] >>> 0 & 255;
|
|
24776
|
-
mac[macpos + 13] = this.h[6] >>> 8 & 255;
|
|
24777
|
-
mac[macpos + 14] = this.h[7] >>> 0 & 255;
|
|
24778
|
-
mac[macpos + 15] = this.h[7] >>> 8 & 255;
|
|
24779
|
-
};
|
|
24780
|
-
poly1305.prototype.update = function(m, mpos, bytes) {
|
|
24781
|
-
var i, want;
|
|
24782
|
-
if (this.leftover) {
|
|
24783
|
-
want = 16 - this.leftover;
|
|
24784
|
-
if (want > bytes)
|
|
24785
|
-
want = bytes;
|
|
24786
|
-
for (i = 0; i < want; i++)
|
|
24787
|
-
this.buffer[this.leftover + i] = m[mpos + i];
|
|
24788
|
-
bytes -= want;
|
|
24789
|
-
mpos += want;
|
|
24790
|
-
this.leftover += want;
|
|
24791
|
-
if (this.leftover < 16)
|
|
24792
|
-
return;
|
|
24793
|
-
this.blocks(this.buffer, 0, 16);
|
|
24794
|
-
this.leftover = 0;
|
|
24795
|
-
}
|
|
24796
|
-
if (bytes >= 16) {
|
|
24797
|
-
want = bytes - bytes % 16;
|
|
24798
|
-
this.blocks(m, mpos, want);
|
|
24799
|
-
mpos += want;
|
|
24800
|
-
bytes -= want;
|
|
24801
|
-
}
|
|
24802
|
-
if (bytes) {
|
|
24803
|
-
for (i = 0; i < bytes; i++)
|
|
24804
|
-
this.buffer[this.leftover + i] = m[mpos + i];
|
|
24805
|
-
this.leftover += bytes;
|
|
24806
|
-
}
|
|
24807
|
-
};
|
|
24808
|
-
function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
|
|
24809
|
-
var s = new poly1305(k);
|
|
24810
|
-
s.update(m, mpos, n);
|
|
24811
|
-
s.finish(out, outpos);
|
|
24812
|
-
return 0;
|
|
24813
|
-
}
|
|
24814
|
-
function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
|
|
24815
|
-
var x = new Uint8Array(16);
|
|
24816
|
-
crypto_onetimeauth(x, 0, m, mpos, n, k);
|
|
24817
|
-
return crypto_verify_16(h, hpos, x, 0);
|
|
24818
|
-
}
|
|
24819
|
-
function crypto_secretbox(c, m, d, n, k) {
|
|
24820
|
-
var i;
|
|
24821
|
-
if (d < 32) return -1;
|
|
24822
|
-
crypto_stream_xor(c, 0, m, 0, d, n, k);
|
|
24823
|
-
crypto_onetimeauth(c, 16, c, 32, d - 32, c);
|
|
24824
|
-
for (i = 0; i < 16; i++) c[i] = 0;
|
|
24825
|
-
return 0;
|
|
24826
|
-
}
|
|
24827
|
-
function crypto_secretbox_open(m, c, d, n, k) {
|
|
24828
|
-
var i;
|
|
24829
|
-
var x = new Uint8Array(32);
|
|
24830
|
-
if (d < 32) return -1;
|
|
24831
|
-
crypto_stream(x, 0, 32, n, k);
|
|
24832
|
-
if (crypto_onetimeauth_verify(c, 16, c, 32, d - 32, x) !== 0) return -1;
|
|
24833
|
-
crypto_stream_xor(m, 0, c, 0, d, n, k);
|
|
24834
|
-
for (i = 0; i < 32; i++) m[i] = 0;
|
|
24835
|
-
return 0;
|
|
24836
|
-
}
|
|
24837
|
-
function set25519(r, a) {
|
|
24838
|
-
var i;
|
|
24839
|
-
for (i = 0; i < 16; i++) r[i] = a[i] | 0;
|
|
24840
|
-
}
|
|
24841
|
-
function car25519(o) {
|
|
24842
|
-
var i, v, c = 1;
|
|
24843
|
-
for (i = 0; i < 16; i++) {
|
|
24844
|
-
v = o[i] + c + 65535;
|
|
24845
|
-
c = Math.floor(v / 65536);
|
|
24846
|
-
o[i] = v - c * 65536;
|
|
24847
|
-
}
|
|
24848
|
-
o[0] += c - 1 + 37 * (c - 1);
|
|
24849
|
-
}
|
|
24850
|
-
function sel25519(p, q, b) {
|
|
24851
|
-
var t, c = ~(b - 1);
|
|
24852
|
-
for (var i = 0; i < 16; i++) {
|
|
24853
|
-
t = c & (p[i] ^ q[i]);
|
|
24854
|
-
p[i] ^= t;
|
|
24855
|
-
q[i] ^= t;
|
|
24856
|
-
}
|
|
24857
|
-
}
|
|
24858
|
-
function pack25519(o, n) {
|
|
24859
|
-
var i, j, b;
|
|
24860
|
-
var m = gf(), t = gf();
|
|
24861
|
-
for (i = 0; i < 16; i++) t[i] = n[i];
|
|
24862
|
-
car25519(t);
|
|
24863
|
-
car25519(t);
|
|
24864
|
-
car25519(t);
|
|
24865
|
-
for (j = 0; j < 2; j++) {
|
|
24866
|
-
m[0] = t[0] - 65517;
|
|
24867
|
-
for (i = 1; i < 15; i++) {
|
|
24868
|
-
m[i] = t[i] - 65535 - (m[i - 1] >> 16 & 1);
|
|
24869
|
-
m[i - 1] &= 65535;
|
|
24870
|
-
}
|
|
24871
|
-
m[15] = t[15] - 32767 - (m[14] >> 16 & 1);
|
|
24872
|
-
b = m[15] >> 16 & 1;
|
|
24873
|
-
m[14] &= 65535;
|
|
24874
|
-
sel25519(t, m, 1 - b);
|
|
24875
|
-
}
|
|
24876
|
-
for (i = 0; i < 16; i++) {
|
|
24877
|
-
o[2 * i] = t[i] & 255;
|
|
24878
|
-
o[2 * i + 1] = t[i] >> 8;
|
|
24879
|
-
}
|
|
24880
|
-
}
|
|
24881
|
-
function neq25519(a, b) {
|
|
24882
|
-
var c = new Uint8Array(32), d = new Uint8Array(32);
|
|
24883
|
-
pack25519(c, a);
|
|
24884
|
-
pack25519(d, b);
|
|
24885
|
-
return crypto_verify_32(c, 0, d, 0);
|
|
24886
|
-
}
|
|
24887
|
-
function par25519(a) {
|
|
24888
|
-
var d = new Uint8Array(32);
|
|
24889
|
-
pack25519(d, a);
|
|
24890
|
-
return d[0] & 1;
|
|
24891
|
-
}
|
|
24892
|
-
function unpack25519(o, n) {
|
|
24893
|
-
var i;
|
|
24894
|
-
for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
|
|
24895
|
-
o[15] &= 32767;
|
|
24896
|
-
}
|
|
24897
|
-
function A(o, a, b) {
|
|
24898
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
|
|
24899
|
-
}
|
|
24900
|
-
function Z(o, a, b) {
|
|
24901
|
-
for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
|
|
24902
|
-
}
|
|
24903
|
-
function M(o, a, b) {
|
|
24904
|
-
var v, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11], b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];
|
|
24905
|
-
v = a[0];
|
|
24906
|
-
t0 += v * b0;
|
|
24907
|
-
t1 += v * b1;
|
|
24908
|
-
t2 += v * b2;
|
|
24909
|
-
t3 += v * b3;
|
|
24910
|
-
t4 += v * b4;
|
|
24911
|
-
t5 += v * b5;
|
|
24912
|
-
t6 += v * b6;
|
|
24913
|
-
t7 += v * b7;
|
|
24914
|
-
t8 += v * b8;
|
|
24915
|
-
t9 += v * b9;
|
|
24916
|
-
t10 += v * b10;
|
|
24917
|
-
t11 += v * b11;
|
|
24918
|
-
t12 += v * b12;
|
|
24919
|
-
t13 += v * b13;
|
|
24920
|
-
t14 += v * b14;
|
|
24921
|
-
t15 += v * b15;
|
|
24922
|
-
v = a[1];
|
|
24923
|
-
t1 += v * b0;
|
|
24924
|
-
t2 += v * b1;
|
|
24925
|
-
t3 += v * b2;
|
|
24926
|
-
t4 += v * b3;
|
|
24927
|
-
t5 += v * b4;
|
|
24928
|
-
t6 += v * b5;
|
|
24929
|
-
t7 += v * b6;
|
|
24930
|
-
t8 += v * b7;
|
|
24931
|
-
t9 += v * b8;
|
|
24932
|
-
t10 += v * b9;
|
|
24933
|
-
t11 += v * b10;
|
|
24934
|
-
t12 += v * b11;
|
|
24935
|
-
t13 += v * b12;
|
|
24936
|
-
t14 += v * b13;
|
|
24937
|
-
t15 += v * b14;
|
|
24938
|
-
t16 += v * b15;
|
|
24939
|
-
v = a[2];
|
|
24940
|
-
t2 += v * b0;
|
|
24941
|
-
t3 += v * b1;
|
|
24942
|
-
t4 += v * b2;
|
|
24943
|
-
t5 += v * b3;
|
|
24944
|
-
t6 += v * b4;
|
|
24945
|
-
t7 += v * b5;
|
|
24946
|
-
t8 += v * b6;
|
|
24947
|
-
t9 += v * b7;
|
|
24948
|
-
t10 += v * b8;
|
|
24949
|
-
t11 += v * b9;
|
|
24950
|
-
t12 += v * b10;
|
|
24951
|
-
t13 += v * b11;
|
|
24952
|
-
t14 += v * b12;
|
|
24953
|
-
t15 += v * b13;
|
|
24954
|
-
t16 += v * b14;
|
|
24955
|
-
t17 += v * b15;
|
|
24956
|
-
v = a[3];
|
|
24957
|
-
t3 += v * b0;
|
|
24958
|
-
t4 += v * b1;
|
|
24959
|
-
t5 += v * b2;
|
|
24960
|
-
t6 += v * b3;
|
|
24961
|
-
t7 += v * b4;
|
|
24962
|
-
t8 += v * b5;
|
|
24963
|
-
t9 += v * b6;
|
|
24964
|
-
t10 += v * b7;
|
|
24965
|
-
t11 += v * b8;
|
|
24966
|
-
t12 += v * b9;
|
|
24967
|
-
t13 += v * b10;
|
|
24968
|
-
t14 += v * b11;
|
|
24969
|
-
t15 += v * b12;
|
|
24970
|
-
t16 += v * b13;
|
|
24971
|
-
t17 += v * b14;
|
|
24972
|
-
t18 += v * b15;
|
|
24973
|
-
v = a[4];
|
|
24974
|
-
t4 += v * b0;
|
|
24975
|
-
t5 += v * b1;
|
|
24976
|
-
t6 += v * b2;
|
|
24977
|
-
t7 += v * b3;
|
|
24978
|
-
t8 += v * b4;
|
|
24979
|
-
t9 += v * b5;
|
|
24980
|
-
t10 += v * b6;
|
|
24981
|
-
t11 += v * b7;
|
|
24982
|
-
t12 += v * b8;
|
|
24983
|
-
t13 += v * b9;
|
|
24984
|
-
t14 += v * b10;
|
|
24985
|
-
t15 += v * b11;
|
|
24986
|
-
t16 += v * b12;
|
|
24987
|
-
t17 += v * b13;
|
|
24988
|
-
t18 += v * b14;
|
|
24989
|
-
t19 += v * b15;
|
|
24990
|
-
v = a[5];
|
|
24991
|
-
t5 += v * b0;
|
|
24992
|
-
t6 += v * b1;
|
|
24993
|
-
t7 += v * b2;
|
|
24994
|
-
t8 += v * b3;
|
|
24995
|
-
t9 += v * b4;
|
|
24996
|
-
t10 += v * b5;
|
|
24997
|
-
t11 += v * b6;
|
|
24998
|
-
t12 += v * b7;
|
|
24999
|
-
t13 += v * b8;
|
|
25000
|
-
t14 += v * b9;
|
|
25001
|
-
t15 += v * b10;
|
|
25002
|
-
t16 += v * b11;
|
|
25003
|
-
t17 += v * b12;
|
|
25004
|
-
t18 += v * b13;
|
|
25005
|
-
t19 += v * b14;
|
|
25006
|
-
t20 += v * b15;
|
|
25007
|
-
v = a[6];
|
|
25008
|
-
t6 += v * b0;
|
|
25009
|
-
t7 += v * b1;
|
|
25010
|
-
t8 += v * b2;
|
|
25011
|
-
t9 += v * b3;
|
|
25012
|
-
t10 += v * b4;
|
|
25013
|
-
t11 += v * b5;
|
|
25014
|
-
t12 += v * b6;
|
|
25015
|
-
t13 += v * b7;
|
|
25016
|
-
t14 += v * b8;
|
|
25017
|
-
t15 += v * b9;
|
|
25018
|
-
t16 += v * b10;
|
|
25019
|
-
t17 += v * b11;
|
|
25020
|
-
t18 += v * b12;
|
|
25021
|
-
t19 += v * b13;
|
|
25022
|
-
t20 += v * b14;
|
|
25023
|
-
t21 += v * b15;
|
|
25024
|
-
v = a[7];
|
|
25025
|
-
t7 += v * b0;
|
|
25026
|
-
t8 += v * b1;
|
|
25027
|
-
t9 += v * b2;
|
|
25028
|
-
t10 += v * b3;
|
|
25029
|
-
t11 += v * b4;
|
|
25030
|
-
t12 += v * b5;
|
|
25031
|
-
t13 += v * b6;
|
|
25032
|
-
t14 += v * b7;
|
|
25033
|
-
t15 += v * b8;
|
|
25034
|
-
t16 += v * b9;
|
|
25035
|
-
t17 += v * b10;
|
|
25036
|
-
t18 += v * b11;
|
|
25037
|
-
t19 += v * b12;
|
|
25038
|
-
t20 += v * b13;
|
|
25039
|
-
t21 += v * b14;
|
|
25040
|
-
t22 += v * b15;
|
|
25041
|
-
v = a[8];
|
|
25042
|
-
t8 += v * b0;
|
|
25043
|
-
t9 += v * b1;
|
|
25044
|
-
t10 += v * b2;
|
|
25045
|
-
t11 += v * b3;
|
|
25046
|
-
t12 += v * b4;
|
|
25047
|
-
t13 += v * b5;
|
|
25048
|
-
t14 += v * b6;
|
|
25049
|
-
t15 += v * b7;
|
|
25050
|
-
t16 += v * b8;
|
|
25051
|
-
t17 += v * b9;
|
|
25052
|
-
t18 += v * b10;
|
|
25053
|
-
t19 += v * b11;
|
|
25054
|
-
t20 += v * b12;
|
|
25055
|
-
t21 += v * b13;
|
|
25056
|
-
t22 += v * b14;
|
|
25057
|
-
t23 += v * b15;
|
|
25058
|
-
v = a[9];
|
|
25059
|
-
t9 += v * b0;
|
|
25060
|
-
t10 += v * b1;
|
|
25061
|
-
t11 += v * b2;
|
|
25062
|
-
t12 += v * b3;
|
|
25063
|
-
t13 += v * b4;
|
|
25064
|
-
t14 += v * b5;
|
|
25065
|
-
t15 += v * b6;
|
|
25066
|
-
t16 += v * b7;
|
|
25067
|
-
t17 += v * b8;
|
|
25068
|
-
t18 += v * b9;
|
|
25069
|
-
t19 += v * b10;
|
|
25070
|
-
t20 += v * b11;
|
|
25071
|
-
t21 += v * b12;
|
|
25072
|
-
t22 += v * b13;
|
|
25073
|
-
t23 += v * b14;
|
|
25074
|
-
t24 += v * b15;
|
|
25075
|
-
v = a[10];
|
|
25076
|
-
t10 += v * b0;
|
|
25077
|
-
t11 += v * b1;
|
|
25078
|
-
t12 += v * b2;
|
|
25079
|
-
t13 += v * b3;
|
|
25080
|
-
t14 += v * b4;
|
|
25081
|
-
t15 += v * b5;
|
|
25082
|
-
t16 += v * b6;
|
|
25083
|
-
t17 += v * b7;
|
|
25084
|
-
t18 += v * b8;
|
|
25085
|
-
t19 += v * b9;
|
|
25086
|
-
t20 += v * b10;
|
|
25087
|
-
t21 += v * b11;
|
|
25088
|
-
t22 += v * b12;
|
|
25089
|
-
t23 += v * b13;
|
|
25090
|
-
t24 += v * b14;
|
|
25091
|
-
t25 += v * b15;
|
|
25092
|
-
v = a[11];
|
|
25093
|
-
t11 += v * b0;
|
|
25094
|
-
t12 += v * b1;
|
|
25095
|
-
t13 += v * b2;
|
|
25096
|
-
t14 += v * b3;
|
|
25097
|
-
t15 += v * b4;
|
|
25098
|
-
t16 += v * b5;
|
|
25099
|
-
t17 += v * b6;
|
|
25100
|
-
t18 += v * b7;
|
|
25101
|
-
t19 += v * b8;
|
|
25102
|
-
t20 += v * b9;
|
|
25103
|
-
t21 += v * b10;
|
|
25104
|
-
t22 += v * b11;
|
|
25105
|
-
t23 += v * b12;
|
|
25106
|
-
t24 += v * b13;
|
|
25107
|
-
t25 += v * b14;
|
|
25108
|
-
t26 += v * b15;
|
|
25109
|
-
v = a[12];
|
|
25110
|
-
t12 += v * b0;
|
|
25111
|
-
t13 += v * b1;
|
|
25112
|
-
t14 += v * b2;
|
|
25113
|
-
t15 += v * b3;
|
|
25114
|
-
t16 += v * b4;
|
|
25115
|
-
t17 += v * b5;
|
|
25116
|
-
t18 += v * b6;
|
|
25117
|
-
t19 += v * b7;
|
|
25118
|
-
t20 += v * b8;
|
|
25119
|
-
t21 += v * b9;
|
|
25120
|
-
t22 += v * b10;
|
|
25121
|
-
t23 += v * b11;
|
|
25122
|
-
t24 += v * b12;
|
|
25123
|
-
t25 += v * b13;
|
|
25124
|
-
t26 += v * b14;
|
|
25125
|
-
t27 += v * b15;
|
|
25126
|
-
v = a[13];
|
|
25127
|
-
t13 += v * b0;
|
|
25128
|
-
t14 += v * b1;
|
|
25129
|
-
t15 += v * b2;
|
|
25130
|
-
t16 += v * b3;
|
|
25131
|
-
t17 += v * b4;
|
|
25132
|
-
t18 += v * b5;
|
|
25133
|
-
t19 += v * b6;
|
|
25134
|
-
t20 += v * b7;
|
|
25135
|
-
t21 += v * b8;
|
|
25136
|
-
t22 += v * b9;
|
|
25137
|
-
t23 += v * b10;
|
|
25138
|
-
t24 += v * b11;
|
|
25139
|
-
t25 += v * b12;
|
|
25140
|
-
t26 += v * b13;
|
|
25141
|
-
t27 += v * b14;
|
|
25142
|
-
t28 += v * b15;
|
|
25143
|
-
v = a[14];
|
|
25144
|
-
t14 += v * b0;
|
|
25145
|
-
t15 += v * b1;
|
|
25146
|
-
t16 += v * b2;
|
|
25147
|
-
t17 += v * b3;
|
|
25148
|
-
t18 += v * b4;
|
|
25149
|
-
t19 += v * b5;
|
|
25150
|
-
t20 += v * b6;
|
|
25151
|
-
t21 += v * b7;
|
|
25152
|
-
t22 += v * b8;
|
|
25153
|
-
t23 += v * b9;
|
|
25154
|
-
t24 += v * b10;
|
|
25155
|
-
t25 += v * b11;
|
|
25156
|
-
t26 += v * b12;
|
|
25157
|
-
t27 += v * b13;
|
|
25158
|
-
t28 += v * b14;
|
|
25159
|
-
t29 += v * b15;
|
|
25160
|
-
v = a[15];
|
|
25161
|
-
t15 += v * b0;
|
|
25162
|
-
t16 += v * b1;
|
|
25163
|
-
t17 += v * b2;
|
|
25164
|
-
t18 += v * b3;
|
|
25165
|
-
t19 += v * b4;
|
|
25166
|
-
t20 += v * b5;
|
|
25167
|
-
t21 += v * b6;
|
|
25168
|
-
t22 += v * b7;
|
|
25169
|
-
t23 += v * b8;
|
|
25170
|
-
t24 += v * b9;
|
|
25171
|
-
t25 += v * b10;
|
|
25172
|
-
t26 += v * b11;
|
|
25173
|
-
t27 += v * b12;
|
|
25174
|
-
t28 += v * b13;
|
|
25175
|
-
t29 += v * b14;
|
|
25176
|
-
t30 += v * b15;
|
|
25177
|
-
t0 += 38 * t16;
|
|
25178
|
-
t1 += 38 * t17;
|
|
25179
|
-
t2 += 38 * t18;
|
|
25180
|
-
t3 += 38 * t19;
|
|
25181
|
-
t4 += 38 * t20;
|
|
25182
|
-
t5 += 38 * t21;
|
|
25183
|
-
t6 += 38 * t22;
|
|
25184
|
-
t7 += 38 * t23;
|
|
25185
|
-
t8 += 38 * t24;
|
|
25186
|
-
t9 += 38 * t25;
|
|
25187
|
-
t10 += 38 * t26;
|
|
25188
|
-
t11 += 38 * t27;
|
|
25189
|
-
t12 += 38 * t28;
|
|
25190
|
-
t13 += 38 * t29;
|
|
25191
|
-
t14 += 38 * t30;
|
|
25192
|
-
c = 1;
|
|
25193
|
-
v = t0 + c + 65535;
|
|
25194
|
-
c = Math.floor(v / 65536);
|
|
25195
|
-
t0 = v - c * 65536;
|
|
25196
|
-
v = t1 + c + 65535;
|
|
25197
|
-
c = Math.floor(v / 65536);
|
|
25198
|
-
t1 = v - c * 65536;
|
|
25199
|
-
v = t2 + c + 65535;
|
|
25200
|
-
c = Math.floor(v / 65536);
|
|
25201
|
-
t2 = v - c * 65536;
|
|
25202
|
-
v = t3 + c + 65535;
|
|
25203
|
-
c = Math.floor(v / 65536);
|
|
25204
|
-
t3 = v - c * 65536;
|
|
25205
|
-
v = t4 + c + 65535;
|
|
25206
|
-
c = Math.floor(v / 65536);
|
|
25207
|
-
t4 = v - c * 65536;
|
|
25208
|
-
v = t5 + c + 65535;
|
|
25209
|
-
c = Math.floor(v / 65536);
|
|
25210
|
-
t5 = v - c * 65536;
|
|
25211
|
-
v = t6 + c + 65535;
|
|
25212
|
-
c = Math.floor(v / 65536);
|
|
25213
|
-
t6 = v - c * 65536;
|
|
25214
|
-
v = t7 + c + 65535;
|
|
25215
|
-
c = Math.floor(v / 65536);
|
|
25216
|
-
t7 = v - c * 65536;
|
|
25217
|
-
v = t8 + c + 65535;
|
|
25218
|
-
c = Math.floor(v / 65536);
|
|
25219
|
-
t8 = v - c * 65536;
|
|
25220
|
-
v = t9 + c + 65535;
|
|
25221
|
-
c = Math.floor(v / 65536);
|
|
25222
|
-
t9 = v - c * 65536;
|
|
25223
|
-
v = t10 + c + 65535;
|
|
25224
|
-
c = Math.floor(v / 65536);
|
|
25225
|
-
t10 = v - c * 65536;
|
|
25226
|
-
v = t11 + c + 65535;
|
|
25227
|
-
c = Math.floor(v / 65536);
|
|
25228
|
-
t11 = v - c * 65536;
|
|
25229
|
-
v = t12 + c + 65535;
|
|
25230
|
-
c = Math.floor(v / 65536);
|
|
25231
|
-
t12 = v - c * 65536;
|
|
25232
|
-
v = t13 + c + 65535;
|
|
25233
|
-
c = Math.floor(v / 65536);
|
|
25234
|
-
t13 = v - c * 65536;
|
|
25235
|
-
v = t14 + c + 65535;
|
|
25236
|
-
c = Math.floor(v / 65536);
|
|
25237
|
-
t14 = v - c * 65536;
|
|
25238
|
-
v = t15 + c + 65535;
|
|
25239
|
-
c = Math.floor(v / 65536);
|
|
25240
|
-
t15 = v - c * 65536;
|
|
25241
|
-
t0 += c - 1 + 37 * (c - 1);
|
|
25242
|
-
c = 1;
|
|
25243
|
-
v = t0 + c + 65535;
|
|
25244
|
-
c = Math.floor(v / 65536);
|
|
25245
|
-
t0 = v - c * 65536;
|
|
25246
|
-
v = t1 + c + 65535;
|
|
25247
|
-
c = Math.floor(v / 65536);
|
|
25248
|
-
t1 = v - c * 65536;
|
|
25249
|
-
v = t2 + c + 65535;
|
|
25250
|
-
c = Math.floor(v / 65536);
|
|
25251
|
-
t2 = v - c * 65536;
|
|
25252
|
-
v = t3 + c + 65535;
|
|
25253
|
-
c = Math.floor(v / 65536);
|
|
25254
|
-
t3 = v - c * 65536;
|
|
25255
|
-
v = t4 + c + 65535;
|
|
25256
|
-
c = Math.floor(v / 65536);
|
|
25257
|
-
t4 = v - c * 65536;
|
|
25258
|
-
v = t5 + c + 65535;
|
|
25259
|
-
c = Math.floor(v / 65536);
|
|
25260
|
-
t5 = v - c * 65536;
|
|
25261
|
-
v = t6 + c + 65535;
|
|
25262
|
-
c = Math.floor(v / 65536);
|
|
25263
|
-
t6 = v - c * 65536;
|
|
25264
|
-
v = t7 + c + 65535;
|
|
25265
|
-
c = Math.floor(v / 65536);
|
|
25266
|
-
t7 = v - c * 65536;
|
|
25267
|
-
v = t8 + c + 65535;
|
|
25268
|
-
c = Math.floor(v / 65536);
|
|
25269
|
-
t8 = v - c * 65536;
|
|
25270
|
-
v = t9 + c + 65535;
|
|
25271
|
-
c = Math.floor(v / 65536);
|
|
25272
|
-
t9 = v - c * 65536;
|
|
25273
|
-
v = t10 + c + 65535;
|
|
25274
|
-
c = Math.floor(v / 65536);
|
|
25275
|
-
t10 = v - c * 65536;
|
|
25276
|
-
v = t11 + c + 65535;
|
|
25277
|
-
c = Math.floor(v / 65536);
|
|
25278
|
-
t11 = v - c * 65536;
|
|
25279
|
-
v = t12 + c + 65535;
|
|
25280
|
-
c = Math.floor(v / 65536);
|
|
25281
|
-
t12 = v - c * 65536;
|
|
25282
|
-
v = t13 + c + 65535;
|
|
25283
|
-
c = Math.floor(v / 65536);
|
|
25284
|
-
t13 = v - c * 65536;
|
|
25285
|
-
v = t14 + c + 65535;
|
|
25286
|
-
c = Math.floor(v / 65536);
|
|
25287
|
-
t14 = v - c * 65536;
|
|
25288
|
-
v = t15 + c + 65535;
|
|
25289
|
-
c = Math.floor(v / 65536);
|
|
25290
|
-
t15 = v - c * 65536;
|
|
25291
|
-
t0 += c - 1 + 37 * (c - 1);
|
|
25292
|
-
o[0] = t0;
|
|
25293
|
-
o[1] = t1;
|
|
25294
|
-
o[2] = t2;
|
|
25295
|
-
o[3] = t3;
|
|
25296
|
-
o[4] = t4;
|
|
25297
|
-
o[5] = t5;
|
|
25298
|
-
o[6] = t6;
|
|
25299
|
-
o[7] = t7;
|
|
25300
|
-
o[8] = t8;
|
|
25301
|
-
o[9] = t9;
|
|
25302
|
-
o[10] = t10;
|
|
25303
|
-
o[11] = t11;
|
|
25304
|
-
o[12] = t12;
|
|
25305
|
-
o[13] = t13;
|
|
25306
|
-
o[14] = t14;
|
|
25307
|
-
o[15] = t15;
|
|
25308
|
-
}
|
|
25309
|
-
function S(o, a) {
|
|
25310
|
-
M(o, a, a);
|
|
25311
|
-
}
|
|
25312
|
-
function inv25519(o, i) {
|
|
25313
|
-
var c = gf();
|
|
25314
|
-
var a;
|
|
25315
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
25316
|
-
for (a = 253; a >= 0; a--) {
|
|
25317
|
-
S(c, c);
|
|
25318
|
-
if (a !== 2 && a !== 4) M(c, c, i);
|
|
25319
|
-
}
|
|
25320
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
25321
|
-
}
|
|
25322
|
-
function pow2523(o, i) {
|
|
25323
|
-
var c = gf();
|
|
25324
|
-
var a;
|
|
25325
|
-
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
25326
|
-
for (a = 250; a >= 0; a--) {
|
|
25327
|
-
S(c, c);
|
|
25328
|
-
if (a !== 1) M(c, c, i);
|
|
25329
|
-
}
|
|
25330
|
-
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
25331
|
-
}
|
|
25332
|
-
function crypto_scalarmult(q, n, p) {
|
|
25333
|
-
var z4 = new Uint8Array(32);
|
|
25334
|
-
var x = new Float64Array(80), r, i;
|
|
25335
|
-
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf();
|
|
25336
|
-
for (i = 0; i < 31; i++) z4[i] = n[i];
|
|
25337
|
-
z4[31] = n[31] & 127 | 64;
|
|
25338
|
-
z4[0] &= 248;
|
|
25339
|
-
unpack25519(x, p);
|
|
25340
|
-
for (i = 0; i < 16; i++) {
|
|
25341
|
-
b[i] = x[i];
|
|
25342
|
-
d[i] = a[i] = c[i] = 0;
|
|
25343
|
-
}
|
|
25344
|
-
a[0] = d[0] = 1;
|
|
25345
|
-
for (i = 254; i >= 0; --i) {
|
|
25346
|
-
r = z4[i >>> 3] >>> (i & 7) & 1;
|
|
25347
|
-
sel25519(a, b, r);
|
|
25348
|
-
sel25519(c, d, r);
|
|
25349
|
-
A(e, a, c);
|
|
25350
|
-
Z(a, a, c);
|
|
25351
|
-
A(c, b, d);
|
|
25352
|
-
Z(b, b, d);
|
|
25353
|
-
S(d, e);
|
|
25354
|
-
S(f, a);
|
|
25355
|
-
M(a, c, a);
|
|
25356
|
-
M(c, b, e);
|
|
25357
|
-
A(e, a, c);
|
|
25358
|
-
Z(a, a, c);
|
|
25359
|
-
S(b, a);
|
|
25360
|
-
Z(c, d, f);
|
|
25361
|
-
M(a, c, _121665);
|
|
25362
|
-
A(a, a, d);
|
|
25363
|
-
M(c, c, a);
|
|
25364
|
-
M(a, d, f);
|
|
25365
|
-
M(d, b, x);
|
|
25366
|
-
S(b, e);
|
|
25367
|
-
sel25519(a, b, r);
|
|
25368
|
-
sel25519(c, d, r);
|
|
25369
|
-
}
|
|
25370
|
-
for (i = 0; i < 16; i++) {
|
|
25371
|
-
x[i + 16] = a[i];
|
|
25372
|
-
x[i + 32] = c[i];
|
|
25373
|
-
x[i + 48] = b[i];
|
|
25374
|
-
x[i + 64] = d[i];
|
|
25375
|
-
}
|
|
25376
|
-
var x32 = x.subarray(32);
|
|
25377
|
-
var x16 = x.subarray(16);
|
|
25378
|
-
inv25519(x32, x32);
|
|
25379
|
-
M(x16, x16, x32);
|
|
25380
|
-
pack25519(q, x16);
|
|
25381
|
-
return 0;
|
|
25382
|
-
}
|
|
25383
|
-
function crypto_scalarmult_base(q, n) {
|
|
25384
|
-
return crypto_scalarmult(q, n, _9);
|
|
25385
|
-
}
|
|
25386
|
-
function crypto_box_keypair(y, x) {
|
|
25387
|
-
randombytes(x, 32);
|
|
25388
|
-
return crypto_scalarmult_base(y, x);
|
|
25389
|
-
}
|
|
25390
|
-
function crypto_box_beforenm(k, y, x) {
|
|
25391
|
-
var s = new Uint8Array(32);
|
|
25392
|
-
crypto_scalarmult(s, x, y);
|
|
25393
|
-
return crypto_core_hsalsa20(k, _0, s, sigma);
|
|
25394
|
-
}
|
|
25395
|
-
var crypto_box_afternm = crypto_secretbox;
|
|
25396
|
-
var crypto_box_open_afternm = crypto_secretbox_open;
|
|
25397
|
-
function crypto_box(c, m, d, n, y, x) {
|
|
25398
|
-
var k = new Uint8Array(32);
|
|
25399
|
-
crypto_box_beforenm(k, y, x);
|
|
25400
|
-
return crypto_box_afternm(c, m, d, n, k);
|
|
25401
|
-
}
|
|
25402
|
-
function crypto_box_open(m, c, d, n, y, x) {
|
|
25403
|
-
var k = new Uint8Array(32);
|
|
25404
|
-
crypto_box_beforenm(k, y, x);
|
|
25405
|
-
return crypto_box_open_afternm(m, c, d, n, k);
|
|
25406
|
-
}
|
|
25407
|
-
var K = [
|
|
25408
|
-
1116352408,
|
|
25409
|
-
3609767458,
|
|
25410
|
-
1899447441,
|
|
25411
|
-
602891725,
|
|
25412
|
-
3049323471,
|
|
25413
|
-
3964484399,
|
|
25414
|
-
3921009573,
|
|
25415
|
-
2173295548,
|
|
25416
|
-
961987163,
|
|
25417
|
-
4081628472,
|
|
25418
|
-
1508970993,
|
|
25419
|
-
3053834265,
|
|
25420
|
-
2453635748,
|
|
25421
|
-
2937671579,
|
|
25422
|
-
2870763221,
|
|
25423
|
-
3664609560,
|
|
25424
|
-
3624381080,
|
|
25425
|
-
2734883394,
|
|
25426
|
-
310598401,
|
|
25427
|
-
1164996542,
|
|
25428
|
-
607225278,
|
|
25429
|
-
1323610764,
|
|
25430
|
-
1426881987,
|
|
25431
|
-
3590304994,
|
|
25432
|
-
1925078388,
|
|
25433
|
-
4068182383,
|
|
25434
|
-
2162078206,
|
|
25435
|
-
991336113,
|
|
25436
|
-
2614888103,
|
|
25437
|
-
633803317,
|
|
25438
|
-
3248222580,
|
|
25439
|
-
3479774868,
|
|
25440
|
-
3835390401,
|
|
25441
|
-
2666613458,
|
|
25442
|
-
4022224774,
|
|
25443
|
-
944711139,
|
|
25444
|
-
264347078,
|
|
25445
|
-
2341262773,
|
|
25446
|
-
604807628,
|
|
25447
|
-
2007800933,
|
|
25448
|
-
770255983,
|
|
25449
|
-
1495990901,
|
|
25450
|
-
1249150122,
|
|
25451
|
-
1856431235,
|
|
25452
|
-
1555081692,
|
|
25453
|
-
3175218132,
|
|
25454
|
-
1996064986,
|
|
25455
|
-
2198950837,
|
|
25456
|
-
2554220882,
|
|
25457
|
-
3999719339,
|
|
25458
|
-
2821834349,
|
|
25459
|
-
766784016,
|
|
25460
|
-
2952996808,
|
|
25461
|
-
2566594879,
|
|
25462
|
-
3210313671,
|
|
25463
|
-
3203337956,
|
|
25464
|
-
3336571891,
|
|
25465
|
-
1034457026,
|
|
25466
|
-
3584528711,
|
|
25467
|
-
2466948901,
|
|
25468
|
-
113926993,
|
|
25469
|
-
3758326383,
|
|
25470
|
-
338241895,
|
|
25471
|
-
168717936,
|
|
25472
|
-
666307205,
|
|
25473
|
-
1188179964,
|
|
25474
|
-
773529912,
|
|
25475
|
-
1546045734,
|
|
25476
|
-
1294757372,
|
|
25477
|
-
1522805485,
|
|
25478
|
-
1396182291,
|
|
25479
|
-
2643833823,
|
|
25480
|
-
1695183700,
|
|
25481
|
-
2343527390,
|
|
25482
|
-
1986661051,
|
|
25483
|
-
1014477480,
|
|
25484
|
-
2177026350,
|
|
25485
|
-
1206759142,
|
|
25486
|
-
2456956037,
|
|
25487
|
-
344077627,
|
|
25488
|
-
2730485921,
|
|
25489
|
-
1290863460,
|
|
25490
|
-
2820302411,
|
|
25491
|
-
3158454273,
|
|
25492
|
-
3259730800,
|
|
25493
|
-
3505952657,
|
|
25494
|
-
3345764771,
|
|
25495
|
-
106217008,
|
|
25496
|
-
3516065817,
|
|
25497
|
-
3606008344,
|
|
25498
|
-
3600352804,
|
|
25499
|
-
1432725776,
|
|
25500
|
-
4094571909,
|
|
25501
|
-
1467031594,
|
|
25502
|
-
275423344,
|
|
25503
|
-
851169720,
|
|
25504
|
-
430227734,
|
|
25505
|
-
3100823752,
|
|
25506
|
-
506948616,
|
|
25507
|
-
1363258195,
|
|
25508
|
-
659060556,
|
|
25509
|
-
3750685593,
|
|
25510
|
-
883997877,
|
|
25511
|
-
3785050280,
|
|
25512
|
-
958139571,
|
|
25513
|
-
3318307427,
|
|
25514
|
-
1322822218,
|
|
25515
|
-
3812723403,
|
|
25516
|
-
1537002063,
|
|
25517
|
-
2003034995,
|
|
25518
|
-
1747873779,
|
|
25519
|
-
3602036899,
|
|
25520
|
-
1955562222,
|
|
25521
|
-
1575990012,
|
|
25522
|
-
2024104815,
|
|
25523
|
-
1125592928,
|
|
25524
|
-
2227730452,
|
|
25525
|
-
2716904306,
|
|
25526
|
-
2361852424,
|
|
25527
|
-
442776044,
|
|
25528
|
-
2428436474,
|
|
25529
|
-
593698344,
|
|
25530
|
-
2756734187,
|
|
25531
|
-
3733110249,
|
|
25532
|
-
3204031479,
|
|
25533
|
-
2999351573,
|
|
25534
|
-
3329325298,
|
|
25535
|
-
3815920427,
|
|
25536
|
-
3391569614,
|
|
25537
|
-
3928383900,
|
|
25538
|
-
3515267271,
|
|
25539
|
-
566280711,
|
|
25540
|
-
3940187606,
|
|
25541
|
-
3454069534,
|
|
25542
|
-
4118630271,
|
|
25543
|
-
4000239992,
|
|
25544
|
-
116418474,
|
|
25545
|
-
1914138554,
|
|
25546
|
-
174292421,
|
|
25547
|
-
2731055270,
|
|
25548
|
-
289380356,
|
|
25549
|
-
3203993006,
|
|
25550
|
-
460393269,
|
|
25551
|
-
320620315,
|
|
25552
|
-
685471733,
|
|
25553
|
-
587496836,
|
|
25554
|
-
852142971,
|
|
25555
|
-
1086792851,
|
|
25556
|
-
1017036298,
|
|
25557
|
-
365543100,
|
|
25558
|
-
1126000580,
|
|
25559
|
-
2618297676,
|
|
25560
|
-
1288033470,
|
|
25561
|
-
3409855158,
|
|
25562
|
-
1501505948,
|
|
25563
|
-
4234509866,
|
|
25564
|
-
1607167915,
|
|
25565
|
-
987167468,
|
|
25566
|
-
1816402316,
|
|
25567
|
-
1246189591
|
|
25568
|
-
];
|
|
25569
|
-
function crypto_hashblocks_hl(hh, hl, m, n) {
|
|
25570
|
-
var wh = new Int32Array(16), wl = new Int32Array(16), bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j, h, l, a, b, c, d;
|
|
25571
|
-
var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];
|
|
25572
|
-
var pos = 0;
|
|
25573
|
-
while (n >= 128) {
|
|
25574
|
-
for (i = 0; i < 16; i++) {
|
|
25575
|
-
j = 8 * i + pos;
|
|
25576
|
-
wh[i] = m[j + 0] << 24 | m[j + 1] << 16 | m[j + 2] << 8 | m[j + 3];
|
|
25577
|
-
wl[i] = m[j + 4] << 24 | m[j + 5] << 16 | m[j + 6] << 8 | m[j + 7];
|
|
25578
|
-
}
|
|
25579
|
-
for (i = 0; i < 80; i++) {
|
|
25580
|
-
bh0 = ah0;
|
|
25581
|
-
bh1 = ah1;
|
|
25582
|
-
bh2 = ah2;
|
|
25583
|
-
bh3 = ah3;
|
|
25584
|
-
bh4 = ah4;
|
|
25585
|
-
bh5 = ah5;
|
|
25586
|
-
bh6 = ah6;
|
|
25587
|
-
bh7 = ah7;
|
|
25588
|
-
bl0 = al0;
|
|
25589
|
-
bl1 = al1;
|
|
25590
|
-
bl2 = al2;
|
|
25591
|
-
bl3 = al3;
|
|
25592
|
-
bl4 = al4;
|
|
25593
|
-
bl5 = al5;
|
|
25594
|
-
bl6 = al6;
|
|
25595
|
-
bl7 = al7;
|
|
25596
|
-
h = ah7;
|
|
25597
|
-
l = al7;
|
|
25598
|
-
a = l & 65535;
|
|
25599
|
-
b = l >>> 16;
|
|
25600
|
-
c = h & 65535;
|
|
25601
|
-
d = h >>> 16;
|
|
25602
|
-
h = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32));
|
|
25603
|
-
l = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32));
|
|
25604
|
-
a += l & 65535;
|
|
25605
|
-
b += l >>> 16;
|
|
25606
|
-
c += h & 65535;
|
|
25607
|
-
d += h >>> 16;
|
|
25608
|
-
h = ah4 & ah5 ^ ~ah4 & ah6;
|
|
25609
|
-
l = al4 & al5 ^ ~al4 & al6;
|
|
25610
|
-
a += l & 65535;
|
|
25611
|
-
b += l >>> 16;
|
|
25612
|
-
c += h & 65535;
|
|
25613
|
-
d += h >>> 16;
|
|
25614
|
-
h = K[i * 2];
|
|
25615
|
-
l = K[i * 2 + 1];
|
|
25616
|
-
a += l & 65535;
|
|
25617
|
-
b += l >>> 16;
|
|
25618
|
-
c += h & 65535;
|
|
25619
|
-
d += h >>> 16;
|
|
25620
|
-
h = wh[i % 16];
|
|
25621
|
-
l = wl[i % 16];
|
|
25622
|
-
a += l & 65535;
|
|
25623
|
-
b += l >>> 16;
|
|
25624
|
-
c += h & 65535;
|
|
25625
|
-
d += h >>> 16;
|
|
25626
|
-
b += a >>> 16;
|
|
25627
|
-
c += b >>> 16;
|
|
25628
|
-
d += c >>> 16;
|
|
25629
|
-
th = c & 65535 | d << 16;
|
|
25630
|
-
tl = a & 65535 | b << 16;
|
|
25631
|
-
h = th;
|
|
25632
|
-
l = tl;
|
|
25633
|
-
a = l & 65535;
|
|
25634
|
-
b = l >>> 16;
|
|
25635
|
-
c = h & 65535;
|
|
25636
|
-
d = h >>> 16;
|
|
25637
|
-
h = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32));
|
|
25638
|
-
l = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32));
|
|
25639
|
-
a += l & 65535;
|
|
25640
|
-
b += l >>> 16;
|
|
25641
|
-
c += h & 65535;
|
|
25642
|
-
d += h >>> 16;
|
|
25643
|
-
h = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2;
|
|
25644
|
-
l = al0 & al1 ^ al0 & al2 ^ al1 & al2;
|
|
25645
|
-
a += l & 65535;
|
|
25646
|
-
b += l >>> 16;
|
|
25647
|
-
c += h & 65535;
|
|
25648
|
-
d += h >>> 16;
|
|
25649
|
-
b += a >>> 16;
|
|
25650
|
-
c += b >>> 16;
|
|
25651
|
-
d += c >>> 16;
|
|
25652
|
-
bh7 = c & 65535 | d << 16;
|
|
25653
|
-
bl7 = a & 65535 | b << 16;
|
|
25654
|
-
h = bh3;
|
|
25655
|
-
l = bl3;
|
|
25656
|
-
a = l & 65535;
|
|
25657
|
-
b = l >>> 16;
|
|
25658
|
-
c = h & 65535;
|
|
25659
|
-
d = h >>> 16;
|
|
25660
|
-
h = th;
|
|
25661
|
-
l = tl;
|
|
25662
|
-
a += l & 65535;
|
|
25663
|
-
b += l >>> 16;
|
|
25664
|
-
c += h & 65535;
|
|
25665
|
-
d += h >>> 16;
|
|
25666
|
-
b += a >>> 16;
|
|
25667
|
-
c += b >>> 16;
|
|
25668
|
-
d += c >>> 16;
|
|
25669
|
-
bh3 = c & 65535 | d << 16;
|
|
25670
|
-
bl3 = a & 65535 | b << 16;
|
|
25671
|
-
ah1 = bh0;
|
|
25672
|
-
ah2 = bh1;
|
|
25673
|
-
ah3 = bh2;
|
|
25674
|
-
ah4 = bh3;
|
|
25675
|
-
ah5 = bh4;
|
|
25676
|
-
ah6 = bh5;
|
|
25677
|
-
ah7 = bh6;
|
|
25678
|
-
ah0 = bh7;
|
|
25679
|
-
al1 = bl0;
|
|
25680
|
-
al2 = bl1;
|
|
25681
|
-
al3 = bl2;
|
|
25682
|
-
al4 = bl3;
|
|
25683
|
-
al5 = bl4;
|
|
25684
|
-
al6 = bl5;
|
|
25685
|
-
al7 = bl6;
|
|
25686
|
-
al0 = bl7;
|
|
25687
|
-
if (i % 16 === 15) {
|
|
25688
|
-
for (j = 0; j < 16; j++) {
|
|
25689
|
-
h = wh[j];
|
|
25690
|
-
l = wl[j];
|
|
25691
|
-
a = l & 65535;
|
|
25692
|
-
b = l >>> 16;
|
|
25693
|
-
c = h & 65535;
|
|
25694
|
-
d = h >>> 16;
|
|
25695
|
-
h = wh[(j + 9) % 16];
|
|
25696
|
-
l = wl[(j + 9) % 16];
|
|
25697
|
-
a += l & 65535;
|
|
25698
|
-
b += l >>> 16;
|
|
25699
|
-
c += h & 65535;
|
|
25700
|
-
d += h >>> 16;
|
|
25701
|
-
th = wh[(j + 1) % 16];
|
|
25702
|
-
tl = wl[(j + 1) % 16];
|
|
25703
|
-
h = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7;
|
|
25704
|
-
l = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7);
|
|
25705
|
-
a += l & 65535;
|
|
25706
|
-
b += l >>> 16;
|
|
25707
|
-
c += h & 65535;
|
|
25708
|
-
d += h >>> 16;
|
|
25709
|
-
th = wh[(j + 14) % 16];
|
|
25710
|
-
tl = wl[(j + 14) % 16];
|
|
25711
|
-
h = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6;
|
|
25712
|
-
l = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6);
|
|
25713
|
-
a += l & 65535;
|
|
25714
|
-
b += l >>> 16;
|
|
25715
|
-
c += h & 65535;
|
|
25716
|
-
d += h >>> 16;
|
|
25717
|
-
b += a >>> 16;
|
|
25718
|
-
c += b >>> 16;
|
|
25719
|
-
d += c >>> 16;
|
|
25720
|
-
wh[j] = c & 65535 | d << 16;
|
|
25721
|
-
wl[j] = a & 65535 | b << 16;
|
|
25722
|
-
}
|
|
25723
|
-
}
|
|
25724
|
-
}
|
|
25725
|
-
h = ah0;
|
|
25726
|
-
l = al0;
|
|
25727
|
-
a = l & 65535;
|
|
25728
|
-
b = l >>> 16;
|
|
25729
|
-
c = h & 65535;
|
|
25730
|
-
d = h >>> 16;
|
|
25731
|
-
h = hh[0];
|
|
25732
|
-
l = hl[0];
|
|
25733
|
-
a += l & 65535;
|
|
25734
|
-
b += l >>> 16;
|
|
25735
|
-
c += h & 65535;
|
|
25736
|
-
d += h >>> 16;
|
|
25737
|
-
b += a >>> 16;
|
|
25738
|
-
c += b >>> 16;
|
|
25739
|
-
d += c >>> 16;
|
|
25740
|
-
hh[0] = ah0 = c & 65535 | d << 16;
|
|
25741
|
-
hl[0] = al0 = a & 65535 | b << 16;
|
|
25742
|
-
h = ah1;
|
|
25743
|
-
l = al1;
|
|
25744
|
-
a = l & 65535;
|
|
25745
|
-
b = l >>> 16;
|
|
25746
|
-
c = h & 65535;
|
|
25747
|
-
d = h >>> 16;
|
|
25748
|
-
h = hh[1];
|
|
25749
|
-
l = hl[1];
|
|
25750
|
-
a += l & 65535;
|
|
25751
|
-
b += l >>> 16;
|
|
25752
|
-
c += h & 65535;
|
|
25753
|
-
d += h >>> 16;
|
|
25754
|
-
b += a >>> 16;
|
|
25755
|
-
c += b >>> 16;
|
|
25756
|
-
d += c >>> 16;
|
|
25757
|
-
hh[1] = ah1 = c & 65535 | d << 16;
|
|
25758
|
-
hl[1] = al1 = a & 65535 | b << 16;
|
|
25759
|
-
h = ah2;
|
|
25760
|
-
l = al2;
|
|
25761
|
-
a = l & 65535;
|
|
25762
|
-
b = l >>> 16;
|
|
25763
|
-
c = h & 65535;
|
|
25764
|
-
d = h >>> 16;
|
|
25765
|
-
h = hh[2];
|
|
25766
|
-
l = hl[2];
|
|
25767
|
-
a += l & 65535;
|
|
25768
|
-
b += l >>> 16;
|
|
25769
|
-
c += h & 65535;
|
|
25770
|
-
d += h >>> 16;
|
|
25771
|
-
b += a >>> 16;
|
|
25772
|
-
c += b >>> 16;
|
|
25773
|
-
d += c >>> 16;
|
|
25774
|
-
hh[2] = ah2 = c & 65535 | d << 16;
|
|
25775
|
-
hl[2] = al2 = a & 65535 | b << 16;
|
|
25776
|
-
h = ah3;
|
|
25777
|
-
l = al3;
|
|
25778
|
-
a = l & 65535;
|
|
25779
|
-
b = l >>> 16;
|
|
25780
|
-
c = h & 65535;
|
|
25781
|
-
d = h >>> 16;
|
|
25782
|
-
h = hh[3];
|
|
25783
|
-
l = hl[3];
|
|
25784
|
-
a += l & 65535;
|
|
25785
|
-
b += l >>> 16;
|
|
25786
|
-
c += h & 65535;
|
|
25787
|
-
d += h >>> 16;
|
|
25788
|
-
b += a >>> 16;
|
|
25789
|
-
c += b >>> 16;
|
|
25790
|
-
d += c >>> 16;
|
|
25791
|
-
hh[3] = ah3 = c & 65535 | d << 16;
|
|
25792
|
-
hl[3] = al3 = a & 65535 | b << 16;
|
|
25793
|
-
h = ah4;
|
|
25794
|
-
l = al4;
|
|
25795
|
-
a = l & 65535;
|
|
25796
|
-
b = l >>> 16;
|
|
25797
|
-
c = h & 65535;
|
|
25798
|
-
d = h >>> 16;
|
|
25799
|
-
h = hh[4];
|
|
25800
|
-
l = hl[4];
|
|
25801
|
-
a += l & 65535;
|
|
25802
|
-
b += l >>> 16;
|
|
25803
|
-
c += h & 65535;
|
|
25804
|
-
d += h >>> 16;
|
|
25805
|
-
b += a >>> 16;
|
|
25806
|
-
c += b >>> 16;
|
|
25807
|
-
d += c >>> 16;
|
|
25808
|
-
hh[4] = ah4 = c & 65535 | d << 16;
|
|
25809
|
-
hl[4] = al4 = a & 65535 | b << 16;
|
|
25810
|
-
h = ah5;
|
|
25811
|
-
l = al5;
|
|
25812
|
-
a = l & 65535;
|
|
25813
|
-
b = l >>> 16;
|
|
25814
|
-
c = h & 65535;
|
|
25815
|
-
d = h >>> 16;
|
|
25816
|
-
h = hh[5];
|
|
25817
|
-
l = hl[5];
|
|
25818
|
-
a += l & 65535;
|
|
25819
|
-
b += l >>> 16;
|
|
25820
|
-
c += h & 65535;
|
|
25821
|
-
d += h >>> 16;
|
|
25822
|
-
b += a >>> 16;
|
|
25823
|
-
c += b >>> 16;
|
|
25824
|
-
d += c >>> 16;
|
|
25825
|
-
hh[5] = ah5 = c & 65535 | d << 16;
|
|
25826
|
-
hl[5] = al5 = a & 65535 | b << 16;
|
|
25827
|
-
h = ah6;
|
|
25828
|
-
l = al6;
|
|
25829
|
-
a = l & 65535;
|
|
25830
|
-
b = l >>> 16;
|
|
25831
|
-
c = h & 65535;
|
|
25832
|
-
d = h >>> 16;
|
|
25833
|
-
h = hh[6];
|
|
25834
|
-
l = hl[6];
|
|
25835
|
-
a += l & 65535;
|
|
25836
|
-
b += l >>> 16;
|
|
25837
|
-
c += h & 65535;
|
|
25838
|
-
d += h >>> 16;
|
|
25839
|
-
b += a >>> 16;
|
|
25840
|
-
c += b >>> 16;
|
|
25841
|
-
d += c >>> 16;
|
|
25842
|
-
hh[6] = ah6 = c & 65535 | d << 16;
|
|
25843
|
-
hl[6] = al6 = a & 65535 | b << 16;
|
|
25844
|
-
h = ah7;
|
|
25845
|
-
l = al7;
|
|
25846
|
-
a = l & 65535;
|
|
25847
|
-
b = l >>> 16;
|
|
25848
|
-
c = h & 65535;
|
|
25849
|
-
d = h >>> 16;
|
|
25850
|
-
h = hh[7];
|
|
25851
|
-
l = hl[7];
|
|
25852
|
-
a += l & 65535;
|
|
25853
|
-
b += l >>> 16;
|
|
25854
|
-
c += h & 65535;
|
|
25855
|
-
d += h >>> 16;
|
|
25856
|
-
b += a >>> 16;
|
|
25857
|
-
c += b >>> 16;
|
|
25858
|
-
d += c >>> 16;
|
|
25859
|
-
hh[7] = ah7 = c & 65535 | d << 16;
|
|
25860
|
-
hl[7] = al7 = a & 65535 | b << 16;
|
|
25861
|
-
pos += 128;
|
|
25862
|
-
n -= 128;
|
|
25863
|
-
}
|
|
25864
|
-
return n;
|
|
25865
|
-
}
|
|
25866
|
-
function crypto_hash(out, m, n) {
|
|
25867
|
-
var hh = new Int32Array(8), hl = new Int32Array(8), x = new Uint8Array(256), i, b = n;
|
|
25868
|
-
hh[0] = 1779033703;
|
|
25869
|
-
hh[1] = 3144134277;
|
|
25870
|
-
hh[2] = 1013904242;
|
|
25871
|
-
hh[3] = 2773480762;
|
|
25872
|
-
hh[4] = 1359893119;
|
|
25873
|
-
hh[5] = 2600822924;
|
|
25874
|
-
hh[6] = 528734635;
|
|
25875
|
-
hh[7] = 1541459225;
|
|
25876
|
-
hl[0] = 4089235720;
|
|
25877
|
-
hl[1] = 2227873595;
|
|
25878
|
-
hl[2] = 4271175723;
|
|
25879
|
-
hl[3] = 1595750129;
|
|
25880
|
-
hl[4] = 2917565137;
|
|
25881
|
-
hl[5] = 725511199;
|
|
25882
|
-
hl[6] = 4215389547;
|
|
25883
|
-
hl[7] = 327033209;
|
|
25884
|
-
crypto_hashblocks_hl(hh, hl, m, n);
|
|
25885
|
-
n %= 128;
|
|
25886
|
-
for (i = 0; i < n; i++) x[i] = m[b - n + i];
|
|
25887
|
-
x[n] = 128;
|
|
25888
|
-
n = 256 - 128 * (n < 112 ? 1 : 0);
|
|
25889
|
-
x[n - 9] = 0;
|
|
25890
|
-
ts64(x, n - 8, b / 536870912 | 0, b << 3);
|
|
25891
|
-
crypto_hashblocks_hl(hh, hl, x, n);
|
|
25892
|
-
for (i = 0; i < 8; i++) ts64(out, 8 * i, hh[i], hl[i]);
|
|
25893
|
-
return 0;
|
|
25894
|
-
}
|
|
25895
|
-
function add(p, q) {
|
|
25896
|
-
var a = gf(), b = gf(), c = gf(), d = gf(), e = gf(), f = gf(), g = gf(), h = gf(), t = gf();
|
|
25897
|
-
Z(a, p[1], p[0]);
|
|
25898
|
-
Z(t, q[1], q[0]);
|
|
25899
|
-
M(a, a, t);
|
|
25900
|
-
A(b, p[0], p[1]);
|
|
25901
|
-
A(t, q[0], q[1]);
|
|
25902
|
-
M(b, b, t);
|
|
25903
|
-
M(c, p[3], q[3]);
|
|
25904
|
-
M(c, c, D2);
|
|
25905
|
-
M(d, p[2], q[2]);
|
|
25906
|
-
A(d, d, d);
|
|
25907
|
-
Z(e, b, a);
|
|
25908
|
-
Z(f, d, c);
|
|
25909
|
-
A(g, d, c);
|
|
25910
|
-
A(h, b, a);
|
|
25911
|
-
M(p[0], e, f);
|
|
25912
|
-
M(p[1], h, g);
|
|
25913
|
-
M(p[2], g, f);
|
|
25914
|
-
M(p[3], e, h);
|
|
25915
|
-
}
|
|
25916
|
-
function cswap(p, q, b) {
|
|
25917
|
-
var i;
|
|
25918
|
-
for (i = 0; i < 4; i++) {
|
|
25919
|
-
sel25519(p[i], q[i], b);
|
|
25920
|
-
}
|
|
25921
|
-
}
|
|
25922
|
-
function pack(r, p) {
|
|
25923
|
-
var tx = gf(), ty = gf(), zi = gf();
|
|
25924
|
-
inv25519(zi, p[2]);
|
|
25925
|
-
M(tx, p[0], zi);
|
|
25926
|
-
M(ty, p[1], zi);
|
|
25927
|
-
pack25519(r, ty);
|
|
25928
|
-
r[31] ^= par25519(tx) << 7;
|
|
25929
|
-
}
|
|
25930
|
-
function scalarmult(p, q, s) {
|
|
25931
|
-
var b, i;
|
|
25932
|
-
set25519(p[0], gf0);
|
|
25933
|
-
set25519(p[1], gf1);
|
|
25934
|
-
set25519(p[2], gf1);
|
|
25935
|
-
set25519(p[3], gf0);
|
|
25936
|
-
for (i = 255; i >= 0; --i) {
|
|
25937
|
-
b = s[i / 8 | 0] >> (i & 7) & 1;
|
|
25938
|
-
cswap(p, q, b);
|
|
25939
|
-
add(q, p);
|
|
25940
|
-
add(p, p);
|
|
25941
|
-
cswap(p, q, b);
|
|
25942
|
-
}
|
|
25943
|
-
}
|
|
25944
|
-
function scalarbase(p, s) {
|
|
25945
|
-
var q = [gf(), gf(), gf(), gf()];
|
|
25946
|
-
set25519(q[0], X);
|
|
25947
|
-
set25519(q[1], Y);
|
|
25948
|
-
set25519(q[2], gf1);
|
|
25949
|
-
M(q[3], X, Y);
|
|
25950
|
-
scalarmult(p, q, s);
|
|
25951
|
-
}
|
|
25952
|
-
function crypto_sign_keypair(pk, sk, seeded) {
|
|
25953
|
-
var d = new Uint8Array(64);
|
|
25954
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
25955
|
-
var i;
|
|
25956
|
-
if (!seeded) randombytes(sk, 32);
|
|
25957
|
-
crypto_hash(d, sk, 32);
|
|
25958
|
-
d[0] &= 248;
|
|
25959
|
-
d[31] &= 127;
|
|
25960
|
-
d[31] |= 64;
|
|
25961
|
-
scalarbase(p, d);
|
|
25962
|
-
pack(pk, p);
|
|
25963
|
-
for (i = 0; i < 32; i++) sk[i + 32] = pk[i];
|
|
25964
|
-
return 0;
|
|
25965
|
-
}
|
|
25966
|
-
var L = new Float64Array([237, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16]);
|
|
25967
|
-
function modL(r, x) {
|
|
25968
|
-
var carry, i, j, k;
|
|
25969
|
-
for (i = 63; i >= 32; --i) {
|
|
25970
|
-
carry = 0;
|
|
25971
|
-
for (j = i - 32, k = i - 12; j < k; ++j) {
|
|
25972
|
-
x[j] += carry - 16 * x[i] * L[j - (i - 32)];
|
|
25973
|
-
carry = Math.floor((x[j] + 128) / 256);
|
|
25974
|
-
x[j] -= carry * 256;
|
|
25975
|
-
}
|
|
25976
|
-
x[j] += carry;
|
|
25977
|
-
x[i] = 0;
|
|
25978
|
-
}
|
|
25979
|
-
carry = 0;
|
|
25980
|
-
for (j = 0; j < 32; j++) {
|
|
25981
|
-
x[j] += carry - (x[31] >> 4) * L[j];
|
|
25982
|
-
carry = x[j] >> 8;
|
|
25983
|
-
x[j] &= 255;
|
|
25984
|
-
}
|
|
25985
|
-
for (j = 0; j < 32; j++) x[j] -= carry * L[j];
|
|
25986
|
-
for (i = 0; i < 32; i++) {
|
|
25987
|
-
x[i + 1] += x[i] >> 8;
|
|
25988
|
-
r[i] = x[i] & 255;
|
|
25989
|
-
}
|
|
25990
|
-
}
|
|
25991
|
-
function reduce(r) {
|
|
25992
|
-
var x = new Float64Array(64), i;
|
|
25993
|
-
for (i = 0; i < 64; i++) x[i] = r[i];
|
|
25994
|
-
for (i = 0; i < 64; i++) r[i] = 0;
|
|
25995
|
-
modL(r, x);
|
|
25996
|
-
}
|
|
25997
|
-
function crypto_sign(sm, m, n, sk) {
|
|
25998
|
-
var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
|
|
25999
|
-
var i, j, x = new Float64Array(64);
|
|
26000
|
-
var p = [gf(), gf(), gf(), gf()];
|
|
26001
|
-
crypto_hash(d, sk, 32);
|
|
26002
|
-
d[0] &= 248;
|
|
26003
|
-
d[31] &= 127;
|
|
26004
|
-
d[31] |= 64;
|
|
26005
|
-
var smlen = n + 64;
|
|
26006
|
-
for (i = 0; i < n; i++) sm[64 + i] = m[i];
|
|
26007
|
-
for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
|
|
26008
|
-
crypto_hash(r, sm.subarray(32), n + 32);
|
|
26009
|
-
reduce(r);
|
|
26010
|
-
scalarbase(p, r);
|
|
26011
|
-
pack(sm, p);
|
|
26012
|
-
for (i = 32; i < 64; i++) sm[i] = sk[i];
|
|
26013
|
-
crypto_hash(h, sm, n + 64);
|
|
26014
|
-
reduce(h);
|
|
26015
|
-
for (i = 0; i < 64; i++) x[i] = 0;
|
|
26016
|
-
for (i = 0; i < 32; i++) x[i] = r[i];
|
|
26017
|
-
for (i = 0; i < 32; i++) {
|
|
26018
|
-
for (j = 0; j < 32; j++) {
|
|
26019
|
-
x[i + j] += h[i] * d[j];
|
|
26020
|
-
}
|
|
26021
|
-
}
|
|
26022
|
-
modL(sm.subarray(32), x);
|
|
26023
|
-
return smlen;
|
|
26024
|
-
}
|
|
26025
|
-
function unpackneg(r, p) {
|
|
26026
|
-
var t = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
|
|
26027
|
-
set25519(r[2], gf1);
|
|
26028
|
-
unpack25519(r[1], p);
|
|
26029
|
-
S(num, r[1]);
|
|
26030
|
-
M(den, num, D);
|
|
26031
|
-
Z(num, num, r[2]);
|
|
26032
|
-
A(den, r[2], den);
|
|
26033
|
-
S(den2, den);
|
|
26034
|
-
S(den4, den2);
|
|
26035
|
-
M(den6, den4, den2);
|
|
26036
|
-
M(t, den6, num);
|
|
26037
|
-
M(t, t, den);
|
|
26038
|
-
pow2523(t, t);
|
|
26039
|
-
M(t, t, num);
|
|
26040
|
-
M(t, t, den);
|
|
26041
|
-
M(t, t, den);
|
|
26042
|
-
M(r[0], t, den);
|
|
26043
|
-
S(chk, r[0]);
|
|
26044
|
-
M(chk, chk, den);
|
|
26045
|
-
if (neq25519(chk, num)) M(r[0], r[0], I);
|
|
26046
|
-
S(chk, r[0]);
|
|
26047
|
-
M(chk, chk, den);
|
|
26048
|
-
if (neq25519(chk, num)) return -1;
|
|
26049
|
-
if (par25519(r[0]) === p[31] >> 7) Z(r[0], gf0, r[0]);
|
|
26050
|
-
M(r[3], r[0], r[1]);
|
|
26051
|
-
return 0;
|
|
26052
|
-
}
|
|
26053
|
-
function crypto_sign_open(m, sm, n, pk) {
|
|
26054
|
-
var i;
|
|
26055
|
-
var t = new Uint8Array(32), h = new Uint8Array(64);
|
|
26056
|
-
var p = [gf(), gf(), gf(), gf()], q = [gf(), gf(), gf(), gf()];
|
|
26057
|
-
if (n < 64) return -1;
|
|
26058
|
-
if (unpackneg(q, pk)) return -1;
|
|
26059
|
-
for (i = 0; i < n; i++) m[i] = sm[i];
|
|
26060
|
-
for (i = 0; i < 32; i++) m[i + 32] = pk[i];
|
|
26061
|
-
crypto_hash(h, m, n);
|
|
26062
|
-
reduce(h);
|
|
26063
|
-
scalarmult(p, q, h);
|
|
26064
|
-
scalarbase(q, sm.subarray(32));
|
|
26065
|
-
add(p, q);
|
|
26066
|
-
pack(t, p);
|
|
26067
|
-
n -= 64;
|
|
26068
|
-
if (crypto_verify_32(sm, 0, t, 0)) {
|
|
26069
|
-
for (i = 0; i < n; i++) m[i] = 0;
|
|
26070
|
-
return -1;
|
|
26071
|
-
}
|
|
26072
|
-
for (i = 0; i < n; i++) m[i] = sm[i + 64];
|
|
26073
|
-
return n;
|
|
26074
|
-
}
|
|
26075
|
-
var crypto_secretbox_KEYBYTES = 32, crypto_secretbox_NONCEBYTES = 24, crypto_secretbox_ZEROBYTES = 32, crypto_secretbox_BOXZEROBYTES = 16, crypto_scalarmult_BYTES = 32, crypto_scalarmult_SCALARBYTES = 32, crypto_box_PUBLICKEYBYTES = 32, crypto_box_SECRETKEYBYTES = 32, crypto_box_BEFORENMBYTES = 32, crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES, crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES, crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES, crypto_sign_BYTES = 64, crypto_sign_PUBLICKEYBYTES = 32, crypto_sign_SECRETKEYBYTES = 64, crypto_sign_SEEDBYTES = 32, crypto_hash_BYTES = 64;
|
|
26076
|
-
nacl6.lowlevel = {
|
|
26077
|
-
crypto_core_hsalsa20,
|
|
26078
|
-
crypto_stream_xor,
|
|
26079
|
-
crypto_stream,
|
|
26080
|
-
crypto_stream_salsa20_xor,
|
|
26081
|
-
crypto_stream_salsa20,
|
|
26082
|
-
crypto_onetimeauth,
|
|
26083
|
-
crypto_onetimeauth_verify,
|
|
26084
|
-
crypto_verify_16,
|
|
26085
|
-
crypto_verify_32,
|
|
26086
|
-
crypto_secretbox,
|
|
26087
|
-
crypto_secretbox_open,
|
|
26088
|
-
crypto_scalarmult,
|
|
26089
|
-
crypto_scalarmult_base,
|
|
26090
|
-
crypto_box_beforenm,
|
|
26091
|
-
crypto_box_afternm,
|
|
26092
|
-
crypto_box,
|
|
26093
|
-
crypto_box_open,
|
|
26094
|
-
crypto_box_keypair,
|
|
26095
|
-
crypto_hash,
|
|
26096
|
-
crypto_sign,
|
|
26097
|
-
crypto_sign_keypair,
|
|
26098
|
-
crypto_sign_open,
|
|
26099
|
-
crypto_secretbox_KEYBYTES,
|
|
26100
|
-
crypto_secretbox_NONCEBYTES,
|
|
26101
|
-
crypto_secretbox_ZEROBYTES,
|
|
26102
|
-
crypto_secretbox_BOXZEROBYTES,
|
|
26103
|
-
crypto_scalarmult_BYTES,
|
|
26104
|
-
crypto_scalarmult_SCALARBYTES,
|
|
26105
|
-
crypto_box_PUBLICKEYBYTES,
|
|
26106
|
-
crypto_box_SECRETKEYBYTES,
|
|
26107
|
-
crypto_box_BEFORENMBYTES,
|
|
26108
|
-
crypto_box_NONCEBYTES,
|
|
26109
|
-
crypto_box_ZEROBYTES,
|
|
26110
|
-
crypto_box_BOXZEROBYTES,
|
|
26111
|
-
crypto_sign_BYTES,
|
|
26112
|
-
crypto_sign_PUBLICKEYBYTES,
|
|
26113
|
-
crypto_sign_SECRETKEYBYTES,
|
|
26114
|
-
crypto_sign_SEEDBYTES,
|
|
26115
|
-
crypto_hash_BYTES,
|
|
26116
|
-
gf,
|
|
26117
|
-
D,
|
|
26118
|
-
L,
|
|
26119
|
-
pack25519,
|
|
26120
|
-
unpack25519,
|
|
26121
|
-
M,
|
|
26122
|
-
A,
|
|
26123
|
-
S,
|
|
26124
|
-
Z,
|
|
26125
|
-
pow2523,
|
|
26126
|
-
add,
|
|
26127
|
-
set25519,
|
|
26128
|
-
modL,
|
|
26129
|
-
scalarmult,
|
|
26130
|
-
scalarbase
|
|
26131
|
-
};
|
|
26132
|
-
function checkLengths(k, n) {
|
|
26133
|
-
if (k.length !== crypto_secretbox_KEYBYTES) throw new Error("bad key size");
|
|
26134
|
-
if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error("bad nonce size");
|
|
26135
|
-
}
|
|
26136
|
-
function checkBoxLengths(pk, sk) {
|
|
26137
|
-
if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error("bad public key size");
|
|
26138
|
-
if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error("bad secret key size");
|
|
26139
|
-
}
|
|
26140
|
-
function checkArrayTypes() {
|
|
26141
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
26142
|
-
if (!(arguments[i] instanceof Uint8Array))
|
|
26143
|
-
throw new TypeError("unexpected type, use Uint8Array");
|
|
26144
|
-
}
|
|
26145
|
-
}
|
|
26146
|
-
function cleanup(arr) {
|
|
26147
|
-
for (var i = 0; i < arr.length; i++) arr[i] = 0;
|
|
26148
|
-
}
|
|
26149
|
-
nacl6.randomBytes = function(n) {
|
|
26150
|
-
var b = new Uint8Array(n);
|
|
26151
|
-
randombytes(b, n);
|
|
26152
|
-
return b;
|
|
26153
|
-
};
|
|
26154
|
-
nacl6.secretbox = function(msg, nonce, key) {
|
|
26155
|
-
checkArrayTypes(msg, nonce, key);
|
|
26156
|
-
checkLengths(key, nonce);
|
|
26157
|
-
var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
|
|
26158
|
-
var c = new Uint8Array(m.length);
|
|
26159
|
-
for (var i = 0; i < msg.length; i++) m[i + crypto_secretbox_ZEROBYTES] = msg[i];
|
|
26160
|
-
crypto_secretbox(c, m, m.length, nonce, key);
|
|
26161
|
-
return c.subarray(crypto_secretbox_BOXZEROBYTES);
|
|
26162
|
-
};
|
|
26163
|
-
nacl6.secretbox.open = function(box, nonce, key) {
|
|
26164
|
-
checkArrayTypes(box, nonce, key);
|
|
26165
|
-
checkLengths(key, nonce);
|
|
26166
|
-
var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
|
|
26167
|
-
var m = new Uint8Array(c.length);
|
|
26168
|
-
for (var i = 0; i < box.length; i++) c[i + crypto_secretbox_BOXZEROBYTES] = box[i];
|
|
26169
|
-
if (c.length < 32) return null;
|
|
26170
|
-
if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
|
|
26171
|
-
return m.subarray(crypto_secretbox_ZEROBYTES);
|
|
26172
|
-
};
|
|
26173
|
-
nacl6.secretbox.keyLength = crypto_secretbox_KEYBYTES;
|
|
26174
|
-
nacl6.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
|
|
26175
|
-
nacl6.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
|
|
26176
|
-
nacl6.scalarMult = function(n, p) {
|
|
26177
|
-
checkArrayTypes(n, p);
|
|
26178
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
26179
|
-
if (p.length !== crypto_scalarmult_BYTES) throw new Error("bad p size");
|
|
26180
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
26181
|
-
crypto_scalarmult(q, n, p);
|
|
26182
|
-
return q;
|
|
26183
|
-
};
|
|
26184
|
-
nacl6.scalarMult.base = function(n) {
|
|
26185
|
-
checkArrayTypes(n);
|
|
26186
|
-
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
26187
|
-
var q = new Uint8Array(crypto_scalarmult_BYTES);
|
|
26188
|
-
crypto_scalarmult_base(q, n);
|
|
26189
|
-
return q;
|
|
26190
|
-
};
|
|
26191
|
-
nacl6.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
|
|
26192
|
-
nacl6.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
|
|
26193
|
-
nacl6.box = function(msg, nonce, publicKey, secretKey) {
|
|
26194
|
-
var k = nacl6.box.before(publicKey, secretKey);
|
|
26195
|
-
return nacl6.secretbox(msg, nonce, k);
|
|
26196
|
-
};
|
|
26197
|
-
nacl6.box.before = function(publicKey, secretKey) {
|
|
26198
|
-
checkArrayTypes(publicKey, secretKey);
|
|
26199
|
-
checkBoxLengths(publicKey, secretKey);
|
|
26200
|
-
var k = new Uint8Array(crypto_box_BEFORENMBYTES);
|
|
26201
|
-
crypto_box_beforenm(k, publicKey, secretKey);
|
|
26202
|
-
return k;
|
|
26203
|
-
};
|
|
26204
|
-
nacl6.box.after = nacl6.secretbox;
|
|
26205
|
-
nacl6.box.open = function(msg, nonce, publicKey, secretKey) {
|
|
26206
|
-
var k = nacl6.box.before(publicKey, secretKey);
|
|
26207
|
-
return nacl6.secretbox.open(msg, nonce, k);
|
|
26208
|
-
};
|
|
26209
|
-
nacl6.box.open.after = nacl6.secretbox.open;
|
|
26210
|
-
nacl6.box.keyPair = function() {
|
|
26211
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
26212
|
-
var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
|
|
26213
|
-
crypto_box_keypair(pk, sk);
|
|
26214
|
-
return { publicKey: pk, secretKey: sk };
|
|
26215
|
-
};
|
|
26216
|
-
nacl6.box.keyPair.fromSecretKey = function(secretKey) {
|
|
26217
|
-
checkArrayTypes(secretKey);
|
|
26218
|
-
if (secretKey.length !== crypto_box_SECRETKEYBYTES)
|
|
26219
|
-
throw new Error("bad secret key size");
|
|
26220
|
-
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
26221
|
-
crypto_scalarmult_base(pk, secretKey);
|
|
26222
|
-
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
26223
|
-
};
|
|
26224
|
-
nacl6.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
|
|
26225
|
-
nacl6.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
|
|
26226
|
-
nacl6.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
|
|
26227
|
-
nacl6.box.nonceLength = crypto_box_NONCEBYTES;
|
|
26228
|
-
nacl6.box.overheadLength = nacl6.secretbox.overheadLength;
|
|
26229
|
-
nacl6.sign = function(msg, secretKey) {
|
|
26230
|
-
checkArrayTypes(msg, secretKey);
|
|
26231
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
26232
|
-
throw new Error("bad secret key size");
|
|
26233
|
-
var signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
26234
|
-
crypto_sign(signedMsg, msg, msg.length, secretKey);
|
|
26235
|
-
return signedMsg;
|
|
26236
|
-
};
|
|
26237
|
-
nacl6.sign.open = function(signedMsg, publicKey) {
|
|
26238
|
-
checkArrayTypes(signedMsg, publicKey);
|
|
26239
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
26240
|
-
throw new Error("bad public key size");
|
|
26241
|
-
var tmp = new Uint8Array(signedMsg.length);
|
|
26242
|
-
var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
|
|
26243
|
-
if (mlen < 0) return null;
|
|
26244
|
-
var m = new Uint8Array(mlen);
|
|
26245
|
-
for (var i = 0; i < m.length; i++) m[i] = tmp[i];
|
|
26246
|
-
return m;
|
|
26247
|
-
};
|
|
26248
|
-
nacl6.sign.detached = function(msg, secretKey) {
|
|
26249
|
-
var signedMsg = nacl6.sign(msg, secretKey);
|
|
26250
|
-
var sig = new Uint8Array(crypto_sign_BYTES);
|
|
26251
|
-
for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
|
|
26252
|
-
return sig;
|
|
26253
|
-
};
|
|
26254
|
-
nacl6.sign.detached.verify = function(msg, sig, publicKey) {
|
|
26255
|
-
checkArrayTypes(msg, sig, publicKey);
|
|
26256
|
-
if (sig.length !== crypto_sign_BYTES)
|
|
26257
|
-
throw new Error("bad signature size");
|
|
26258
|
-
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
26259
|
-
throw new Error("bad public key size");
|
|
26260
|
-
var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
26261
|
-
var m = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
26262
|
-
var i;
|
|
26263
|
-
for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
|
|
26264
|
-
for (i = 0; i < msg.length; i++) sm[i + crypto_sign_BYTES] = msg[i];
|
|
26265
|
-
return crypto_sign_open(m, sm, sm.length, publicKey) >= 0;
|
|
26266
|
-
};
|
|
26267
|
-
nacl6.sign.keyPair = function() {
|
|
26268
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
26269
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
26270
|
-
crypto_sign_keypair(pk, sk);
|
|
26271
|
-
return { publicKey: pk, secretKey: sk };
|
|
26272
|
-
};
|
|
26273
|
-
nacl6.sign.keyPair.fromSecretKey = function(secretKey) {
|
|
26274
|
-
checkArrayTypes(secretKey);
|
|
26275
|
-
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
26276
|
-
throw new Error("bad secret key size");
|
|
26277
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
26278
|
-
for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32 + i];
|
|
26279
|
-
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
26280
|
-
};
|
|
26281
|
-
nacl6.sign.keyPair.fromSeed = function(seed) {
|
|
26282
|
-
checkArrayTypes(seed);
|
|
26283
|
-
if (seed.length !== crypto_sign_SEEDBYTES)
|
|
26284
|
-
throw new Error("bad seed size");
|
|
26285
|
-
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
26286
|
-
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
26287
|
-
for (var i = 0; i < 32; i++) sk[i] = seed[i];
|
|
26288
|
-
crypto_sign_keypair(pk, sk, true);
|
|
26289
|
-
return { publicKey: pk, secretKey: sk };
|
|
26290
|
-
};
|
|
26291
|
-
nacl6.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
|
|
26292
|
-
nacl6.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
|
|
26293
|
-
nacl6.sign.seedLength = crypto_sign_SEEDBYTES;
|
|
26294
|
-
nacl6.sign.signatureLength = crypto_sign_BYTES;
|
|
26295
|
-
nacl6.hash = function(msg) {
|
|
26296
|
-
checkArrayTypes(msg);
|
|
26297
|
-
var h = new Uint8Array(crypto_hash_BYTES);
|
|
26298
|
-
crypto_hash(h, msg, msg.length);
|
|
26299
|
-
return h;
|
|
26300
|
-
};
|
|
26301
|
-
nacl6.hash.hashLength = crypto_hash_BYTES;
|
|
26302
|
-
nacl6.verify = function(x, y) {
|
|
26303
|
-
checkArrayTypes(x, y);
|
|
26304
|
-
if (x.length === 0 || y.length === 0) return false;
|
|
26305
|
-
if (x.length !== y.length) return false;
|
|
26306
|
-
return vn(x, 0, y, 0, x.length) === 0 ? true : false;
|
|
26307
|
-
};
|
|
26308
|
-
nacl6.setPRNG = function(fn) {
|
|
26309
|
-
randombytes = fn;
|
|
26310
|
-
};
|
|
26311
|
-
(function() {
|
|
26312
|
-
var crypto = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
26313
|
-
if (crypto && crypto.getRandomValues) {
|
|
26314
|
-
var QUOTA = 65536;
|
|
26315
|
-
nacl6.setPRNG(function(x, n) {
|
|
26316
|
-
var i, v = new Uint8Array(n);
|
|
26317
|
-
for (i = 0; i < n; i += QUOTA) {
|
|
26318
|
-
crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
|
|
26319
|
-
}
|
|
26320
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
26321
|
-
cleanup(v);
|
|
26322
|
-
});
|
|
26323
|
-
} else if (typeof __require2 !== "undefined") {
|
|
26324
|
-
crypto = __require2("crypto");
|
|
26325
|
-
if (crypto && crypto.randomBytes) {
|
|
26326
|
-
nacl6.setPRNG(function(x, n) {
|
|
26327
|
-
var i, v = crypto.randomBytes(n);
|
|
26328
|
-
for (i = 0; i < n; i++) x[i] = v[i];
|
|
26329
|
-
cleanup(v);
|
|
26330
|
-
});
|
|
26331
|
-
}
|
|
26332
|
-
}
|
|
26333
|
-
})();
|
|
26334
|
-
})(typeof module !== "undefined" && module.exports ? module.exports : self.nacl = self.nacl || {});
|
|
26335
|
-
}
|
|
26336
|
-
});
|
|
26337
24077
|
BACKEND_URL = process.env.PAIGY_BACKEND_URL ?? "https://paigy.ai";
|
|
26338
24078
|
NETWORK_MSG = `Can't reach ${BACKEND_URL} \u2014 the connection was blocked or dropped before an HTTP response. If this agent runs in a sandboxed environment with a network allowlist (e.g. Claude Code on the web, CI), ask the user to add the Paigy domain (paigy.ai) to the environment's allowed domains, then retry.`;
|
|
26339
24079
|
PROXY_ENV = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy"];
|
|
@@ -26349,7 +24089,6 @@ var init_dist = __esm({
|
|
|
26349
24089
|
const v = process.env[key];
|
|
26350
24090
|
return v && v.trim() ? v : void 0;
|
|
26351
24091
|
};
|
|
26352
|
-
SESSION_ID = envSession("PAIGY_SESSION_ID") ?? envSession("CLAUDE_CODE_SESSION_ID") ?? envSession("CODEX_THREAD_ID") ?? envSession("CODEX_SESSION_ID") ?? WORKSPACE_ID;
|
|
26353
24092
|
ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
26354
24093
|
defaultOptions = {
|
|
26355
24094
|
name: void 0,
|
|
@@ -26713,32 +24452,28 @@ var init_dist = __esm({
|
|
|
26713
24452
|
};
|
|
26714
24453
|
OPTIONS_MIN = 2;
|
|
26715
24454
|
OPTIONS_MAX = 6;
|
|
26716
|
-
|
|
26717
|
-
|
|
26718
|
-
|
|
26719
|
-
|
|
26720
|
-
// A DecisionNeed is settled only by an answer in the shape THIS ask declares. Bundle news,
|
|
26721
|
-
// findings and a decision into one, and the person answers whichever part engaged them —
|
|
26722
|
-
// which settles nothing, leaves the need open, and gets them asked again. On call 619c5a92
|
|
26723
|
-
// one ask carried a briefing, a side question ("the ring should show the agent's name now —
|
|
26724
|
-
// what did you actually see?") and a one-of-four about how far an erase reaches. The owner
|
|
26725
|
-
// answered the side question. The need stayed open; the card asked again. Of the 45 call
|
|
26726
|
-
// asks carrying a decision, 27 are over 600 characters.
|
|
26727
|
-
//
|
|
26728
|
-
// Sending them separately costs nothing, because a CALL contact joins the call already
|
|
26729
|
-
// happening (`goal/store.ts`, JOIN BEFORE MINTING) — several contacts on one Goal arrive as
|
|
26730
|
-
// one call, planned as its turns, and each keeps its own settleable need.
|
|
24455
|
+
AskInputSchema = external_exports.object({
|
|
24456
|
+
id: external_exports.string().optional().describe("Optional idempotency key or client-side ID for this specific ask."),
|
|
24457
|
+
parentId: external_exports.string().uuid().optional().describe("Optional explicit parent Goal ID. If omitted, the platform's semantic router will auto-cluster it."),
|
|
24458
|
+
repo: external_exports.string().optional().describe("Optional repository context."),
|
|
26731
24459
|
ask: external_exports.string().trim().min(1).max(1e4).describe(
|
|
26732
24460
|
"The question, and only what is needed to answer it. News, progress and findings are their own contact \u2014 a call contact JOINS a call already happening, so several arrive as one call. Do not bundle: a DecisionNeed is settled only by an answer in the shape this ask declares, so someone who answers the part that interested them settles nothing and is asked again."
|
|
26733
24461
|
),
|
|
24462
|
+
options: external_exports.array(external_exports.object({
|
|
24463
|
+
label: external_exports.string().trim().min(1).max(1e3),
|
|
24464
|
+
hint: external_exports.string().trim().max(500).describe("Optional short projection of consequence or action if this option is chosen.").optional(),
|
|
24465
|
+
image: external_exports.string().url().optional(),
|
|
24466
|
+
html: external_exports.string().max(16384).describe("Optional sandboxed HTML/CSS preview. No JavaScript or network; inline CSS and data: URIs only. It renders edge-to-edge in a responsive card 200pt tall (about 320pt wide on a phone, with the next option peeking beside it), so fit the HTML to that viewport.").optional()
|
|
24467
|
+
}).strict()).min(2).max(6).optional()
|
|
24468
|
+
}).strict();
|
|
24469
|
+
StartContactSchema = external_exports.object({
|
|
24470
|
+
asks: external_exports.array(AskInputSchema).min(1).describe("The list of asks/questions to pose. They will be semantically clustered by the API."),
|
|
26734
24471
|
waiting: external_exports.enum(["none", "hard"]).default("none"),
|
|
26735
|
-
channel: external_exports.enum(["notification", "call"]).default("notification")
|
|
26736
|
-
options: external_exports.array(external_exports.object({ label: external_exports.string().trim().min(1).max(1e3), image: external_exports.string().url().optional(), html: external_exports.string().max(16384).optional() }).strict()).min(2).max(6).optional(),
|
|
26737
|
-
threadId: external_exports.string().uuid().optional().describe("Continue an existing Thread: the threadId a prior Delivery returned. Omit to start a new Thread.")
|
|
24472
|
+
channel: external_exports.enum(["notification", "call"]).default("notification")
|
|
26738
24473
|
}).strict();
|
|
26739
24474
|
ContactSchema = external_exports.union([StartContactSchema, external_exports.object({ deliveryId: external_exports.string().uuid() }).strict()]);
|
|
26740
24475
|
CONTACT_SCHEMA = { type: "object", ...mcpInputSchema(ContactSchema) };
|
|
26741
|
-
CONTACT_DESCRIPTION = "Contact the user
|
|
24476
|
+
CONTACT_DESCRIPTION = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. The platform will semantically cluster your asks under the correct Goals automatically. Notification returns immediately; collect durable answers with check_replies. On stdio, a Call holds one cancellable ~45s window; continue with ONLY {deliveryId}. Never bundle multiple questions into a single 'ask' string; pass them as separate objects in the 'asks' array.";
|
|
26742
24477
|
CreateGoalSchema = external_exports.object({
|
|
26743
24478
|
outcome: external_exports.string().trim().min(1).max(1e4),
|
|
26744
24479
|
/** The work's NAME (#2115) — one to five words, how a person refers to it out loud ("the night
|
|
@@ -26750,7 +24485,6 @@ var init_dist = __esm({
|
|
|
26750
24485
|
* (owner, on the call of 2026-09-14: "let's do the reference with the threading"). A
|
|
26751
24486
|
* reference only: the owner reads it through `get_thread`, which does its own scoping, and
|
|
26752
24487
|
* the writer refuses a thread belonging to another account. */
|
|
26753
|
-
contextThreadId: external_exports.string().uuid().optional(),
|
|
26754
24488
|
/** THE GOAL THIS ONE BELONGS UNDER (owner, 2026-09-15: "the ask I gave for the design doc
|
|
26755
24489
|
* didn't get created as a child goal of the voice UI goal, which is how it should've
|
|
26756
24490
|
* worked"). It could not have been: this door took no parent, so the only route was
|
|
@@ -26758,12 +24492,15 @@ var init_dist = __esm({
|
|
|
26758
24492
|
* took the short one. The hierarchy has been modelled since Goals existed and had been used
|
|
26759
24493
|
* ZERO times in 2,031 of them. Absent, the server judges it against the caller's open Goals
|
|
26760
24494
|
* (`apps/api/src/goal/intake.ts`). The writer refuses a Goal belonging to another account. */
|
|
26761
|
-
parentGoalId: external_exports.string().uuid().optional()
|
|
24495
|
+
parentGoalId: external_exports.string().uuid().optional(),
|
|
24496
|
+
/** The repository or project identifier this Goal belongs to (#2280) — e.g. "owner/repo" or
|
|
24497
|
+
* repo name. Delegated work inherits this from its parent Goal when omitted. */
|
|
24498
|
+
repo: external_exports.string().trim().min(1).max(200).optional()
|
|
26762
24499
|
});
|
|
26763
24500
|
CreateGoalToolSchema = CreateGoalSchema.extend({
|
|
26764
24501
|
idempotencyKey: CreateGoalSchema.shape.idempotencyKey.optional().describe("Optional. One is minted per call; pass your own only so a retry lands on the same Goal.")
|
|
26765
24502
|
}).strict();
|
|
26766
|
-
CREATE_GOAL_DESCRIPTION = 'Create a durable Goal for an outcome. Without parentGoalId it is placed against your open Goals: if one already IS this work, that Goal comes back (existing: true) and nothing new is created \u2014 continue it; if the work belongs under one, it is created there (parentGoalId in the receipt); otherwise it is a root. Pass parentGoalId yourself to put it under a specific Goal. Pass title to name it in one to five words, as a person would refer to it out loud ("the night rings") \u2014 it heads every list and is spoken on a call; without one the brain writes it. Admission only: the owner must claim it before doing work, then update it as it advances. Returns an admission receipt with goalId, current state, revision, ownerParticipant, and the next step; no Goal content or execution lease.';
|
|
24503
|
+
CREATE_GOAL_DESCRIPTION = 'Create a durable Goal for an outcome. Without parentGoalId it is placed against your open Goals: if one already IS this work, that Goal comes back (existing: true) and nothing new is created \u2014 continue it; if the work belongs under one, it is created there (parentGoalId in the receipt); otherwise it is a root. Pass parentGoalId yourself to put it under a specific Goal. Pass repo to anchor the work to a specific repository ("owner/repo" or repo name); delegated children inherit it. Pass title to name it in one to five words, as a person would refer to it out loud ("the night rings") \u2014 it heads every list and is spoken on a call; without one the brain writes it. Admission only: the owner must claim it before doing work, then update it as it advances. Returns an admission receipt with goalId, current state, revision, ownerParticipant, and the next step; no Goal content or execution lease.';
|
|
26767
24504
|
UpdateGoalSchema = external_exports.object({
|
|
26768
24505
|
revision: external_exports.number().int().positive(),
|
|
26769
24506
|
changes: external_exports.object({
|
|
@@ -26840,10 +24577,11 @@ var init_dist = __esm({
|
|
|
26840
24577
|
OptionSchema = external_exports.object({
|
|
26841
24578
|
id: external_exports.string(),
|
|
26842
24579
|
label: external_exports.string(),
|
|
24580
|
+
hint: external_exports.string().max(500).describe("Optional short projection of consequence or action if this option is chosen (e.g. 'Reruns test suite', 'Merges to main').").optional(),
|
|
26843
24581
|
// .describe() flows into the MCP contact JSON schema (zodToJsonSchema), so
|
|
26844
24582
|
// the constraints below are what an agent reads when deciding to use these.
|
|
26845
24583
|
html: external_exports.string().max(16384).describe(
|
|
26846
|
-
"Optional sandboxed HTML/CSS preview for a visual 'pick one' (shown in the option card). Untrusted-sandboxed: NO JavaScript, NO external network or images \u2014 inline CSS and data: URIs only; <=16KB. Use for layout/CSS mockups, tables, diffs. For a hosted image use `image` instead."
|
|
24584
|
+
"Optional sandboxed HTML/CSS preview for a visual 'pick one' (shown in the option card). Untrusted-sandboxed: NO JavaScript, NO external network or images \u2014 inline CSS and data: URIs only; <=16KB. Rendered edge-to-edge in a responsive card that is 200pt tall (about 320pt wide on a phone, with the next option peeking beside it); make your HTML fit that viewport. Use for layout/CSS mockups, tables, diffs. For a hosted image use `image` instead."
|
|
26847
24585
|
).optional(),
|
|
26848
24586
|
image: external_exports.string().url().describe(
|
|
26849
24587
|
"Optional image URL rendered as the option's preview (plain image, not sandboxed). For agent-generated HTML/CSS mockups, use `html` instead."
|
|
@@ -26934,23 +24672,6 @@ var init_dist = __esm({
|
|
|
26934
24672
|
* when `parentId` became the conversation handle: `parentId` says WHERE, this
|
|
26935
24673
|
* says HOW. */
|
|
26936
24674
|
clarifies: external_exports.string().optional(),
|
|
26937
|
-
/** E2EE (text lane): when the pairing is E2EE, the sealed replacements for the
|
|
26938
|
-
* plaintext content fields, keyed by field name. FINALIZED wire shape (was
|
|
26939
|
-
* provisional in the storage PR): a per-field map `{ context?, options?,
|
|
26940
|
-
* visuals? }` of opaque Envelopes — one seal per present content field, so a
|
|
26941
|
-
* message with no options/visuals seals only `context`. It COEXISTS with the
|
|
26942
|
-
* plaintext fields by mutual exclusion: the superRefine below requires that
|
|
26943
|
-
* when `envelope` is present the plaintext `context`/`options`/`visuals` are
|
|
26944
|
-
* ABSENT (and vice-versa), so a row is either fully plaintext or fully sealed —
|
|
26945
|
-
* never a readable half. The server persists this OPAQUELY into
|
|
26946
|
-
* notifications.envelope and relays it blindly; it never decrypts. Absent =
|
|
26947
|
-
* today's plaintext path (context/options/visuals carry the cleartext).
|
|
26948
|
-
* z.lazy because EnvelopeSchema is declared further down (E2EE section). */
|
|
26949
|
-
envelope: external_exports.object({
|
|
26950
|
-
context: external_exports.lazy(() => EnvelopeSchema).optional(),
|
|
26951
|
-
options: external_exports.lazy(() => EnvelopeSchema).optional(),
|
|
26952
|
-
visuals: external_exports.lazy(() => EnvelopeSchema).optional()
|
|
26953
|
-
}).optional(),
|
|
26954
24675
|
select: SelectShapeSchema.optional().describe(
|
|
26955
24676
|
"How the user answers \u2014 required on the fully-shaped form, pick the shape that fits the question: 'one' = pick one option, 'many' = pick several, 'rank' = pick & order (each needs `options`); 'confirm' = yes/no or approve/deny; 'text' = free-form reply only (status updates, open questions). 'confirm' and 'text' take no options. Omit only when sending the simplified `ask` form \u2014 the broker picks the shape."
|
|
26956
24677
|
),
|
|
@@ -27004,22 +24725,6 @@ var init_dist = __esm({
|
|
|
27004
24725
|
});
|
|
27005
24726
|
NotifyRequestSchema = NotifyRequestFields.superRefine((r, ctx) => {
|
|
27006
24727
|
if (r.workId && r.goalId) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["goalId"], message: "pass goalId or workId, not both" });
|
|
27007
|
-
const sealed = !!r.envelope;
|
|
27008
|
-
if (sealed) {
|
|
27009
|
-
if (!r.envelope?.context)
|
|
27010
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["envelope", "context"], message: "sealed request must include envelope.context" });
|
|
27011
|
-
for (const f of ["context", "options", "visuals"]) {
|
|
27012
|
-
if (r[f] !== void 0)
|
|
27013
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: [f], message: `E2EE request must not carry plaintext ${f} \u2014 it's sealed in envelope.${f}` });
|
|
27014
|
-
}
|
|
27015
|
-
if (r.points !== void 0)
|
|
27016
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["points"], message: "E2EE request must not carry plaintext points" });
|
|
27017
|
-
if (r.ask !== void 0)
|
|
27018
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["ask"], message: "E2EE request must not carry a plaintext ask \u2014 derive the shape agent-side and seal it" });
|
|
27019
|
-
if (r.needs !== void 0)
|
|
27020
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["needs"], message: "E2EE request must not carry plaintext needs" });
|
|
27021
|
-
return;
|
|
27022
|
-
}
|
|
27023
24728
|
if (r.ask !== void 0) {
|
|
27024
24729
|
for (const f of ["context", "select", "points"]) {
|
|
27025
24730
|
if (r[f] !== void 0)
|
|
@@ -27094,13 +24799,6 @@ var init_dist = __esm({
|
|
|
27094
24799
|
workId: external_exports.string().uuid().optional(),
|
|
27095
24800
|
decisionId: external_exports.string().uuid().optional(),
|
|
27096
24801
|
answer: UserAnswerSchema,
|
|
27097
|
-
/** E2EE: present when the answer is sealed. The server relays the opaque answer
|
|
27098
|
-
* envelope + the plaintext `ignored` status hint; the receiving agent OPENS it
|
|
27099
|
-
* with its device key and re-derives the real UserAnswer, treating a mismatch
|
|
27100
|
-
* against `ignored` as tampering. Absent = today's plaintext answer (in `answer`).
|
|
27101
|
-
* On a sealed reply the plaintext `answer` is a placeholder (kind reflects only
|
|
27102
|
-
* the `ignored` bit) — never the real content, which stays sealed. */
|
|
27103
|
-
sealed: external_exports.lazy(() => SealedAnswerSchema).optional(),
|
|
27104
24802
|
/** WHAT THE AGENT CANNOT KNOW FROM THE FIELDS BESIDE IT (owner, 2026-09-04, issue
|
|
27105
24803
|
* #1537). One line, built from the record: the ask and the caller's reply VERBATIM,
|
|
27106
24804
|
* the notification they belong to, and the `contact` call that reaches the person
|
|
@@ -27322,21 +25020,6 @@ var init_dist = __esm({
|
|
|
27322
25020
|
blocking: external_exports.boolean().default(false),
|
|
27323
25021
|
/** The user's locked-in answer; present only for replied items (GET /api/replied/:id). */
|
|
27324
25022
|
answer: UserAnswerSchema.optional(),
|
|
27325
|
-
/** E2EE (text lane): the sealed content this item carries when the pairing is E2EE, in
|
|
27326
|
-
* place of the plaintext `context`/`options`/`visuals` (which the operator would
|
|
27327
|
-
* otherwise read). A per-field map of opaque Envelopes — the SAME shape as
|
|
27328
|
-
* NotifyRequest.envelope. The native app decrypts it locally via openNotification;
|
|
27329
|
-
* web / an un-enrolled device can't and renders a locked placeholder. Absent = today's
|
|
27330
|
-
* plaintext item (context carries the cleartext), so plaintext items are unchanged. */
|
|
27331
|
-
envelope: external_exports.object({
|
|
27332
|
-
context: external_exports.lazy(() => EnvelopeSchema).optional(),
|
|
27333
|
-
options: external_exports.lazy(() => EnvelopeSchema).optional(),
|
|
27334
|
-
visuals: external_exports.lazy(() => EnvelopeSchema).optional()
|
|
27335
|
-
}).optional(),
|
|
27336
|
-
/** E2EE: the agent's device X25519 public key to seal the user's answer BACK to (the
|
|
27337
|
-
* sender the phone replies to). Sourced server-side from this item's pairing credential.
|
|
27338
|
-
* Present only alongside `envelope`; the phone seals via sealAnswer(answer, this, id). */
|
|
27339
|
-
agentX25519: external_exports.string().optional(),
|
|
27340
25023
|
/** THE TARGET FACTS A CARD RENDERS (#1796 point 5, 2026-09-11): the Delivery it is a view of,
|
|
27341
25024
|
* that Delivery's kind, the request Entry, the Goals it answers for, the exact DecisionNeed (none
|
|
27342
25025
|
* for a request that asks nothing), whether its content is sealed, and that Goal's state. The
|
|
@@ -27434,13 +25117,6 @@ var init_dist = __esm({
|
|
|
27434
25117
|
* setting. Absent = a spoken time can't be landed, so the reminder rides the next
|
|
27435
25118
|
* call — honest about what we know. */
|
|
27436
25119
|
timezone: external_exports.string().min(1).max(64).optional(),
|
|
27437
|
-
/** Account E2EE state (text lane): 'off' (default) = today's plaintext; 'on' =
|
|
27438
|
-
* content is sealed end-to-end between the local agent and the phone. Like
|
|
27439
|
-
* voiceMode, OPTIONAL and NOT defaulted so a stale client PATCHing the full
|
|
27440
|
-
* settings object without it can't silently flip the account's E2EE state.
|
|
27441
|
-
* Absent = leave unchanged on write, 'off' on read (see store.ts). The demo
|
|
27442
|
-
* account is plaintext by construction and refuses any non-'off' value. */
|
|
27443
|
-
e2eeMode: external_exports.enum(["off", "on"]).optional(),
|
|
27444
25120
|
/** Rung-2 broker tuning (#381). Optional and NOT defaulted, same stale-client
|
|
27445
25121
|
* clobber guard as voiceMode: absent = leave unchanged on write. */
|
|
27446
25122
|
broker: BrokerTuningSchema.optional()
|
|
@@ -27630,6 +25306,8 @@ var init_dist = __esm({
|
|
|
27630
25306
|
blocked: external_exports.boolean().default(false),
|
|
27631
25307
|
/** Every decision need on it, open or settled — the page decides which to show. */
|
|
27632
25308
|
questions: external_exports.array(QueueQuestionSchema).default([]),
|
|
25309
|
+
/** The repository or project identifier this Goal belongs to (#2280), null if untracked. */
|
|
25310
|
+
repo: external_exports.string().nullable().optional(),
|
|
27633
25311
|
createdAt: external_exports.string(),
|
|
27634
25312
|
updatedAt: external_exports.string().nullable().default(null)
|
|
27635
25313
|
});
|
|
@@ -27743,54 +25421,12 @@ var init_dist = __esm({
|
|
|
27743
25421
|
* carries credentials; only a `poll` registration can come back with null here. */
|
|
27744
25422
|
realtime: external_exports.object({ url: external_exports.string(), anonKey: external_exports.string() }).nullable()
|
|
27745
25423
|
});
|
|
27746
|
-
EnvelopeRecipientSchema = external_exports.object({
|
|
27747
|
-
keyId: external_exports.string(),
|
|
27748
|
-
epk: external_exports.string(),
|
|
27749
|
-
wnonce: external_exports.string(),
|
|
27750
|
-
wrap: external_exports.string()
|
|
27751
|
-
});
|
|
27752
|
-
EnvelopeHeaderSchema = external_exports.object({
|
|
27753
|
-
field: external_exports.enum(["context", "options", "visuals", "answer"]),
|
|
27754
|
-
kind: external_exports.string(),
|
|
27755
|
-
senderRole: external_exports.enum(["agent", "user"]),
|
|
27756
|
-
recipientKeyIds: external_exports.array(external_exports.string()),
|
|
27757
|
-
seq: external_exports.number().int().nonnegative()
|
|
27758
|
-
});
|
|
27759
|
-
EnvelopeSchema = external_exports.object({
|
|
27760
|
-
v: external_exports.literal(1),
|
|
27761
|
-
alg: external_exports.literal("x25519-xsalsa20poly1305"),
|
|
27762
|
-
msgId: external_exports.string(),
|
|
27763
|
-
hdr: EnvelopeHeaderSchema,
|
|
27764
|
-
recipients: external_exports.array(EnvelopeRecipientSchema).min(1),
|
|
27765
|
-
nonce: external_exports.string(),
|
|
27766
|
-
ct: external_exports.string()
|
|
27767
|
-
});
|
|
27768
|
-
SealedAnswerSchema = external_exports.object({
|
|
27769
|
-
ignored: external_exports.boolean(),
|
|
27770
|
-
envelope: EnvelopeSchema
|
|
27771
|
-
});
|
|
27772
|
-
DeviceCredentialSchema = external_exports.object({
|
|
27773
|
-
deviceId: external_exports.string(),
|
|
27774
|
-
kind: external_exports.enum(["phone", "web", "agent"]),
|
|
27775
|
-
x25519Pub: external_exports.string(),
|
|
27776
|
-
ed25519Pub: external_exports.string(),
|
|
27777
|
-
sig: external_exports.string()
|
|
27778
|
-
});
|
|
27779
|
-
DeviceRosterSchema = external_exports.object({
|
|
27780
|
-
uikPub: external_exports.string(),
|
|
27781
|
-
devices: external_exports.array(DeviceCredentialSchema)
|
|
27782
|
-
});
|
|
27783
25424
|
WakeNudgeSchema = external_exports.object({
|
|
27784
25425
|
kind: external_exports.enum(["reply", "request", "callback"]),
|
|
27785
25426
|
notificationId: external_exports.string().optional(),
|
|
27786
25427
|
parentId: external_exports.string()
|
|
27787
25428
|
});
|
|
27788
25429
|
PairingStatusSchema = external_exports.enum(["pending", "approved", "denied", "expired"]);
|
|
27789
|
-
PairingRevealSchema = external_exports.object({
|
|
27790
|
-
x25519: external_exports.string(),
|
|
27791
|
-
ed25519: external_exports.string(),
|
|
27792
|
-
nonce: external_exports.string()
|
|
27793
|
-
});
|
|
27794
25430
|
DeviceCodeSchema = external_exports.object({
|
|
27795
25431
|
device_code: external_exports.string(),
|
|
27796
25432
|
user_code: external_exports.string(),
|
|
@@ -27810,19 +25446,7 @@ var init_dist = __esm({
|
|
|
27810
25446
|
* (seen live: PAIGY-5T, 2026-07-21). Remove once a newer binary is the floor. */
|
|
27811
25447
|
agent: external_exports.string().optional(),
|
|
27812
25448
|
device: external_exports.string().nullable(),
|
|
27813
|
-
status: PairingStatusSchema
|
|
27814
|
-
proto: external_exports.string().nullable().optional(),
|
|
27815
|
-
agent_commitment: external_exports.string().nullable().optional(),
|
|
27816
|
-
// Ca
|
|
27817
|
-
agent_reveal: PairingRevealSchema.nullable().optional(),
|
|
27818
|
-
// present once the agent reveals
|
|
27819
|
-
agent_credential: DeviceCredentialSchema.nullable().optional(),
|
|
27820
|
-
// the phone's UIK-signed cred over the agent's keys — the agent fetches it here to finalizeE2ee
|
|
27821
|
-
// The phone's reveal + identity key, exposed here so a GATED agent (e2ee_mode='on', token
|
|
27822
|
-
// withheld until e2ee=true) can compute the SAS WITHOUT a token. Public keys — same safety
|
|
27823
|
-
// class as agent_reveal above. Present only once the phone reveals; null otherwise.
|
|
27824
|
-
phone_reveal: PairingRevealSchema.nullable().optional(),
|
|
27825
|
-
uik_pub: external_exports.string().nullable().optional()
|
|
25449
|
+
status: PairingStatusSchema
|
|
27826
25450
|
});
|
|
27827
25451
|
DeviceTokenSchema = external_exports.object({
|
|
27828
25452
|
access_token: external_exports.string(),
|
|
@@ -27841,8 +25465,6 @@ var init_dist = __esm({
|
|
|
27841
25465
|
* landed in the FIRST granted workspace and the agent rediscovered its own repo from
|
|
27842
25466
|
* the thread each time (host.ts, live catch 2026-08-06 — prompt-papered until now). */
|
|
27843
25467
|
workspace: external_exports.string().nullable().optional(),
|
|
27844
|
-
phone_reveal: PairingRevealSchema.nullable().optional(),
|
|
27845
|
-
// present once the phone reveals
|
|
27846
25468
|
uik_pub: external_exports.string().nullable().optional()
|
|
27847
25469
|
});
|
|
27848
25470
|
SupportRequestSchema = external_exports.object({
|
|
@@ -27864,21 +25486,8 @@ var init_dist = __esm({
|
|
|
27864
25486
|
"other"
|
|
27865
25487
|
// anything else — the note carries it.
|
|
27866
25488
|
]);
|
|
27867
|
-
|
|
27868
|
-
|
|
27869
|
-
resolution: FeedbackResolutionSchema,
|
|
27870
|
-
transform: TransformSchema,
|
|
27871
|
-
message: external_exports.string(),
|
|
27872
|
-
childIds: external_exports.array(external_exports.string()).optional()
|
|
27873
|
-
});
|
|
27874
|
-
import_tweetnacl = __toESM2(require_nacl_fast(), 1);
|
|
27875
|
-
import_tweetnacl2 = __toESM2(require_nacl_fast(), 1);
|
|
27876
|
-
import_tweetnacl3 = __toESM2(require_nacl_fast(), 1);
|
|
27877
|
-
import_tweetnacl4 = __toESM2(require_nacl_fast(), 1);
|
|
27878
|
-
import_tweetnacl5 = __toESM2(require_nacl_fast(), 1);
|
|
27879
|
-
AGENT_NAME = process.env.PAIGY_AGENT || sessionSlot();
|
|
27880
|
-
TOKEN_PATH = join2(homedir2(), ".paigy", "token.json");
|
|
27881
|
-
KEY_PATH = join2(homedir2(), ".paigy", "key.json");
|
|
25489
|
+
TOKEN_PATH = join22(homedir22(), ".paigy", "token.json");
|
|
25490
|
+
KEY_PATH = join22(homedir22(), ".paigy", "key.json");
|
|
27882
25491
|
sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
27883
25492
|
UnpairedError = class extends Error {
|
|
27884
25493
|
constructor() {
|
|
@@ -31383,7 +28992,7 @@ var require_sync_inflate = __commonJS({
|
|
|
31383
28992
|
if (typeof asyncCb === "function") {
|
|
31384
28993
|
return zlib.Inflate._processChunk.call(this, chunk, flushFlag, asyncCb);
|
|
31385
28994
|
}
|
|
31386
|
-
let
|
|
28995
|
+
let self = this;
|
|
31387
28996
|
let availInBefore = chunk && chunk.length;
|
|
31388
28997
|
let availOutBefore = this._chunkSize - this._offset;
|
|
31389
28998
|
let leftToInflate = this._maxLength;
|
|
@@ -31395,14 +29004,14 @@ var require_sync_inflate = __commonJS({
|
|
|
31395
29004
|
error = err;
|
|
31396
29005
|
});
|
|
31397
29006
|
function handleChunk(availInAfter, availOutAfter) {
|
|
31398
|
-
if (
|
|
29007
|
+
if (self._hadError) {
|
|
31399
29008
|
return;
|
|
31400
29009
|
}
|
|
31401
29010
|
let have = availOutBefore - availOutAfter;
|
|
31402
29011
|
assert(have >= 0, "have should not go down");
|
|
31403
29012
|
if (have > 0) {
|
|
31404
|
-
let out =
|
|
31405
|
-
|
|
29013
|
+
let out = self._buffer.slice(self._offset, self._offset + have);
|
|
29014
|
+
self._offset += have;
|
|
31406
29015
|
if (out.length > leftToInflate) {
|
|
31407
29016
|
out = out.slice(0, leftToInflate);
|
|
31408
29017
|
}
|
|
@@ -31413,10 +29022,10 @@ var require_sync_inflate = __commonJS({
|
|
|
31413
29022
|
return false;
|
|
31414
29023
|
}
|
|
31415
29024
|
}
|
|
31416
|
-
if (availOutAfter === 0 ||
|
|
31417
|
-
availOutBefore =
|
|
31418
|
-
|
|
31419
|
-
|
|
29025
|
+
if (availOutAfter === 0 || self._offset >= self._chunkSize) {
|
|
29026
|
+
availOutBefore = self._chunkSize;
|
|
29027
|
+
self._offset = 0;
|
|
29028
|
+
self._buffer = Buffer.allocUnsafe(self._chunkSize);
|
|
31420
29029
|
}
|
|
31421
29030
|
if (availOutAfter === 0) {
|
|
31422
29031
|
inOff += availInBefore - availInAfter;
|
|
@@ -33152,7 +30761,7 @@ function onEnter(input, onLine) {
|
|
|
33152
30761
|
init_dist();
|
|
33153
30762
|
var import_qrcode = __toESM(require_lib(), 1);
|
|
33154
30763
|
import { hostname } from "os";
|
|
33155
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as
|
|
30764
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
33156
30765
|
import { execFile as execFile2, execSync } from "child_process";
|
|
33157
30766
|
import { homedir as homedir8 } from "os";
|
|
33158
30767
|
import { join as join7 } from "path";
|
|
@@ -34789,32 +32398,28 @@ function mcpInputSchema2(s) {
|
|
|
34789
32398
|
delete schema.$schema;
|
|
34790
32399
|
return draft20202(schema);
|
|
34791
32400
|
}
|
|
34792
|
-
var
|
|
34793
|
-
|
|
34794
|
-
|
|
34795
|
-
|
|
34796
|
-
// A DecisionNeed is settled only by an answer in the shape THIS ask declares. Bundle news,
|
|
34797
|
-
// findings and a decision into one, and the person answers whichever part engaged them —
|
|
34798
|
-
// which settles nothing, leaves the need open, and gets them asked again. On call 619c5a92
|
|
34799
|
-
// one ask carried a briefing, a side question ("the ring should show the agent's name now —
|
|
34800
|
-
// what did you actually see?") and a one-of-four about how far an erase reaches. The owner
|
|
34801
|
-
// answered the side question. The need stayed open; the card asked again. Of the 45 call
|
|
34802
|
-
// asks carrying a decision, 27 are over 600 characters.
|
|
34803
|
-
//
|
|
34804
|
-
// Sending them separately costs nothing, because a CALL contact joins the call already
|
|
34805
|
-
// happening (`goal/store.ts`, JOIN BEFORE MINTING) — several contacts on one Goal arrive as
|
|
34806
|
-
// one call, planned as its turns, and each keeps its own settleable need.
|
|
32401
|
+
var AskInputSchema2 = external_exports.object({
|
|
32402
|
+
id: external_exports.string().optional().describe("Optional idempotency key or client-side ID for this specific ask."),
|
|
32403
|
+
parentId: external_exports.string().uuid().optional().describe("Optional explicit parent Goal ID. If omitted, the platform's semantic router will auto-cluster it."),
|
|
32404
|
+
repo: external_exports.string().optional().describe("Optional repository context."),
|
|
34807
32405
|
ask: external_exports.string().trim().min(1).max(1e4).describe(
|
|
34808
32406
|
"The question, and only what is needed to answer it. News, progress and findings are their own contact \u2014 a call contact JOINS a call already happening, so several arrive as one call. Do not bundle: a DecisionNeed is settled only by an answer in the shape this ask declares, so someone who answers the part that interested them settles nothing and is asked again."
|
|
34809
32407
|
),
|
|
32408
|
+
options: external_exports.array(external_exports.object({
|
|
32409
|
+
label: external_exports.string().trim().min(1).max(1e3),
|
|
32410
|
+
hint: external_exports.string().trim().max(500).describe("Optional short projection of consequence or action if this option is chosen.").optional(),
|
|
32411
|
+
image: external_exports.string().url().optional(),
|
|
32412
|
+
html: external_exports.string().max(16384).describe("Optional sandboxed HTML/CSS preview. No JavaScript or network; inline CSS and data: URIs only. It renders edge-to-edge in a responsive card 200pt tall (about 320pt wide on a phone, with the next option peeking beside it), so fit the HTML to that viewport.").optional()
|
|
32413
|
+
}).strict()).min(2).max(6).optional()
|
|
32414
|
+
}).strict();
|
|
32415
|
+
var StartContactSchema2 = external_exports.object({
|
|
32416
|
+
asks: external_exports.array(AskInputSchema2).min(1).describe("The list of asks/questions to pose. They will be semantically clustered by the API."),
|
|
34810
32417
|
waiting: external_exports.enum(["none", "hard"]).default("none"),
|
|
34811
|
-
channel: external_exports.enum(["notification", "call"]).default("notification")
|
|
34812
|
-
options: external_exports.array(external_exports.object({ label: external_exports.string().trim().min(1).max(1e3), image: external_exports.string().url().optional(), html: external_exports.string().max(16384).optional() }).strict()).min(2).max(6).optional(),
|
|
34813
|
-
threadId: external_exports.string().uuid().optional().describe("Continue an existing Thread: the threadId a prior Delivery returned. Omit to start a new Thread.")
|
|
32418
|
+
channel: external_exports.enum(["notification", "call"]).default("notification")
|
|
34814
32419
|
}).strict();
|
|
34815
32420
|
var ContactSchema2 = external_exports.union([StartContactSchema2, external_exports.object({ deliveryId: external_exports.string().uuid() }).strict()]);
|
|
34816
32421
|
var CONTACT_SCHEMA2 = { type: "object", ...mcpInputSchema2(ContactSchema2) };
|
|
34817
|
-
var CONTACT_DESCRIPTION2 = "Contact the user
|
|
32422
|
+
var CONTACT_DESCRIPTION2 = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. The platform will semantically cluster your asks under the correct Goals automatically. Notification returns immediately; collect durable answers with check_replies. On stdio, a Call holds one cancellable ~45s window; continue with ONLY {deliveryId}. Never bundle multiple questions into a single 'ask' string; pass them as separate objects in the 'asks' array.";
|
|
34818
32423
|
var CreateGoalSchema2 = external_exports.object({
|
|
34819
32424
|
outcome: external_exports.string().trim().min(1).max(1e4),
|
|
34820
32425
|
/** The work's NAME (#2115) — one to five words, how a person refers to it out loud ("the night
|
|
@@ -34826,7 +32431,6 @@ var CreateGoalSchema2 = external_exports.object({
|
|
|
34826
32431
|
* (owner, on the call of 2026-09-14: "let's do the reference with the threading"). A
|
|
34827
32432
|
* reference only: the owner reads it through `get_thread`, which does its own scoping, and
|
|
34828
32433
|
* the writer refuses a thread belonging to another account. */
|
|
34829
|
-
contextThreadId: external_exports.string().uuid().optional(),
|
|
34830
32434
|
/** THE GOAL THIS ONE BELONGS UNDER (owner, 2026-09-15: "the ask I gave for the design doc
|
|
34831
32435
|
* didn't get created as a child goal of the voice UI goal, which is how it should've
|
|
34832
32436
|
* worked"). It could not have been: this door took no parent, so the only route was
|
|
@@ -34834,12 +32438,15 @@ var CreateGoalSchema2 = external_exports.object({
|
|
|
34834
32438
|
* took the short one. The hierarchy has been modelled since Goals existed and had been used
|
|
34835
32439
|
* ZERO times in 2,031 of them. Absent, the server judges it against the caller's open Goals
|
|
34836
32440
|
* (`apps/api/src/goal/intake.ts`). The writer refuses a Goal belonging to another account. */
|
|
34837
|
-
parentGoalId: external_exports.string().uuid().optional()
|
|
32441
|
+
parentGoalId: external_exports.string().uuid().optional(),
|
|
32442
|
+
/** The repository or project identifier this Goal belongs to (#2280) — e.g. "owner/repo" or
|
|
32443
|
+
* repo name. Delegated work inherits this from its parent Goal when omitted. */
|
|
32444
|
+
repo: external_exports.string().trim().min(1).max(200).optional()
|
|
34838
32445
|
});
|
|
34839
32446
|
var CreateGoalToolSchema2 = CreateGoalSchema2.extend({
|
|
34840
32447
|
idempotencyKey: CreateGoalSchema2.shape.idempotencyKey.optional().describe("Optional. One is minted per call; pass your own only so a retry lands on the same Goal.")
|
|
34841
32448
|
}).strict();
|
|
34842
|
-
var CREATE_GOAL_DESCRIPTION2 = 'Create a durable Goal for an outcome. Without parentGoalId it is placed against your open Goals: if one already IS this work, that Goal comes back (existing: true) and nothing new is created \u2014 continue it; if the work belongs under one, it is created there (parentGoalId in the receipt); otherwise it is a root. Pass parentGoalId yourself to put it under a specific Goal. Pass title to name it in one to five words, as a person would refer to it out loud ("the night rings") \u2014 it heads every list and is spoken on a call; without one the brain writes it. Admission only: the owner must claim it before doing work, then update it as it advances. Returns an admission receipt with goalId, current state, revision, ownerParticipant, and the next step; no Goal content or execution lease.';
|
|
32449
|
+
var CREATE_GOAL_DESCRIPTION2 = 'Create a durable Goal for an outcome. Without parentGoalId it is placed against your open Goals: if one already IS this work, that Goal comes back (existing: true) and nothing new is created \u2014 continue it; if the work belongs under one, it is created there (parentGoalId in the receipt); otherwise it is a root. Pass parentGoalId yourself to put it under a specific Goal. Pass repo to anchor the work to a specific repository ("owner/repo" or repo name); delegated children inherit it. Pass title to name it in one to five words, as a person would refer to it out loud ("the night rings") \u2014 it heads every list and is spoken on a call; without one the brain writes it. Admission only: the owner must claim it before doing work, then update it as it advances. Returns an admission receipt with goalId, current state, revision, ownerParticipant, and the next step; no Goal content or execution lease.';
|
|
34843
32450
|
var UpdateGoalSchema2 = external_exports.object({
|
|
34844
32451
|
revision: external_exports.number().int().positive(),
|
|
34845
32452
|
changes: external_exports.object({
|
|
@@ -34931,10 +32538,11 @@ var TransformSchema2 = external_exports.enum([
|
|
|
34931
32538
|
var OptionSchema2 = external_exports.object({
|
|
34932
32539
|
id: external_exports.string(),
|
|
34933
32540
|
label: external_exports.string(),
|
|
32541
|
+
hint: external_exports.string().max(500).describe("Optional short projection of consequence or action if this option is chosen (e.g. 'Reruns test suite', 'Merges to main').").optional(),
|
|
34934
32542
|
// .describe() flows into the MCP contact JSON schema (zodToJsonSchema), so
|
|
34935
32543
|
// the constraints below are what an agent reads when deciding to use these.
|
|
34936
32544
|
html: external_exports.string().max(16384).describe(
|
|
34937
|
-
"Optional sandboxed HTML/CSS preview for a visual 'pick one' (shown in the option card). Untrusted-sandboxed: NO JavaScript, NO external network or images \u2014 inline CSS and data: URIs only; <=16KB. Use for layout/CSS mockups, tables, diffs. For a hosted image use `image` instead."
|
|
32545
|
+
"Optional sandboxed HTML/CSS preview for a visual 'pick one' (shown in the option card). Untrusted-sandboxed: NO JavaScript, NO external network or images \u2014 inline CSS and data: URIs only; <=16KB. Rendered edge-to-edge in a responsive card that is 200pt tall (about 320pt wide on a phone, with the next option peeking beside it); make your HTML fit that viewport. Use for layout/CSS mockups, tables, diffs. For a hosted image use `image` instead."
|
|
34938
32546
|
).optional(),
|
|
34939
32547
|
image: external_exports.string().url().describe(
|
|
34940
32548
|
"Optional image URL rendered as the option's preview (plain image, not sandboxed). For agent-generated HTML/CSS mockups, use `html` instead."
|
|
@@ -35025,23 +32633,6 @@ var NotifyRequestFields2 = external_exports.object({
|
|
|
35025
32633
|
* when `parentId` became the conversation handle: `parentId` says WHERE, this
|
|
35026
32634
|
* says HOW. */
|
|
35027
32635
|
clarifies: external_exports.string().optional(),
|
|
35028
|
-
/** E2EE (text lane): when the pairing is E2EE, the sealed replacements for the
|
|
35029
|
-
* plaintext content fields, keyed by field name. FINALIZED wire shape (was
|
|
35030
|
-
* provisional in the storage PR): a per-field map `{ context?, options?,
|
|
35031
|
-
* visuals? }` of opaque Envelopes — one seal per present content field, so a
|
|
35032
|
-
* message with no options/visuals seals only `context`. It COEXISTS with the
|
|
35033
|
-
* plaintext fields by mutual exclusion: the superRefine below requires that
|
|
35034
|
-
* when `envelope` is present the plaintext `context`/`options`/`visuals` are
|
|
35035
|
-
* ABSENT (and vice-versa), so a row is either fully plaintext or fully sealed —
|
|
35036
|
-
* never a readable half. The server persists this OPAQUELY into
|
|
35037
|
-
* notifications.envelope and relays it blindly; it never decrypts. Absent =
|
|
35038
|
-
* today's plaintext path (context/options/visuals carry the cleartext).
|
|
35039
|
-
* z.lazy because EnvelopeSchema is declared further down (E2EE section). */
|
|
35040
|
-
envelope: external_exports.object({
|
|
35041
|
-
context: external_exports.lazy(() => EnvelopeSchema2).optional(),
|
|
35042
|
-
options: external_exports.lazy(() => EnvelopeSchema2).optional(),
|
|
35043
|
-
visuals: external_exports.lazy(() => EnvelopeSchema2).optional()
|
|
35044
|
-
}).optional(),
|
|
35045
32636
|
select: SelectShapeSchema2.optional().describe(
|
|
35046
32637
|
"How the user answers \u2014 required on the fully-shaped form, pick the shape that fits the question: 'one' = pick one option, 'many' = pick several, 'rank' = pick & order (each needs `options`); 'confirm' = yes/no or approve/deny; 'text' = free-form reply only (status updates, open questions). 'confirm' and 'text' take no options. Omit only when sending the simplified `ask` form \u2014 the broker picks the shape."
|
|
35047
32638
|
),
|
|
@@ -35095,22 +32686,6 @@ var NotifyRequestFields2 = external_exports.object({
|
|
|
35095
32686
|
});
|
|
35096
32687
|
var NotifyRequestSchema2 = NotifyRequestFields2.superRefine((r, ctx) => {
|
|
35097
32688
|
if (r.workId && r.goalId) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["goalId"], message: "pass goalId or workId, not both" });
|
|
35098
|
-
const sealed = !!r.envelope;
|
|
35099
|
-
if (sealed) {
|
|
35100
|
-
if (!r.envelope?.context)
|
|
35101
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["envelope", "context"], message: "sealed request must include envelope.context" });
|
|
35102
|
-
for (const f of ["context", "options", "visuals"]) {
|
|
35103
|
-
if (r[f] !== void 0)
|
|
35104
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: [f], message: `E2EE request must not carry plaintext ${f} \u2014 it's sealed in envelope.${f}` });
|
|
35105
|
-
}
|
|
35106
|
-
if (r.points !== void 0)
|
|
35107
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["points"], message: "E2EE request must not carry plaintext points" });
|
|
35108
|
-
if (r.ask !== void 0)
|
|
35109
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["ask"], message: "E2EE request must not carry a plaintext ask \u2014 derive the shape agent-side and seal it" });
|
|
35110
|
-
if (r.needs !== void 0)
|
|
35111
|
-
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["needs"], message: "E2EE request must not carry plaintext needs" });
|
|
35112
|
-
return;
|
|
35113
|
-
}
|
|
35114
32689
|
if (r.ask !== void 0) {
|
|
35115
32690
|
for (const f of ["context", "select", "points"]) {
|
|
35116
32691
|
if (r[f] !== void 0)
|
|
@@ -35185,13 +32760,6 @@ var AwaitItemSchema2 = external_exports.discriminatedUnion("type", [
|
|
|
35185
32760
|
workId: external_exports.string().uuid().optional(),
|
|
35186
32761
|
decisionId: external_exports.string().uuid().optional(),
|
|
35187
32762
|
answer: UserAnswerSchema2,
|
|
35188
|
-
/** E2EE: present when the answer is sealed. The server relays the opaque answer
|
|
35189
|
-
* envelope + the plaintext `ignored` status hint; the receiving agent OPENS it
|
|
35190
|
-
* with its device key and re-derives the real UserAnswer, treating a mismatch
|
|
35191
|
-
* against `ignored` as tampering. Absent = today's plaintext answer (in `answer`).
|
|
35192
|
-
* On a sealed reply the plaintext `answer` is a placeholder (kind reflects only
|
|
35193
|
-
* the `ignored` bit) — never the real content, which stays sealed. */
|
|
35194
|
-
sealed: external_exports.lazy(() => SealedAnswerSchema2).optional(),
|
|
35195
32763
|
/** WHAT THE AGENT CANNOT KNOW FROM THE FIELDS BESIDE IT (owner, 2026-09-04, issue
|
|
35196
32764
|
* #1537). One line, built from the record: the ask and the caller's reply VERBATIM,
|
|
35197
32765
|
* the notification they belong to, and the `contact` call that reaches the person
|
|
@@ -35413,21 +32981,6 @@ var InboxItemSchema2 = external_exports.object({
|
|
|
35413
32981
|
blocking: external_exports.boolean().default(false),
|
|
35414
32982
|
/** The user's locked-in answer; present only for replied items (GET /api/replied/:id). */
|
|
35415
32983
|
answer: UserAnswerSchema2.optional(),
|
|
35416
|
-
/** E2EE (text lane): the sealed content this item carries when the pairing is E2EE, in
|
|
35417
|
-
* place of the plaintext `context`/`options`/`visuals` (which the operator would
|
|
35418
|
-
* otherwise read). A per-field map of opaque Envelopes — the SAME shape as
|
|
35419
|
-
* NotifyRequest.envelope. The native app decrypts it locally via openNotification;
|
|
35420
|
-
* web / an un-enrolled device can't and renders a locked placeholder. Absent = today's
|
|
35421
|
-
* plaintext item (context carries the cleartext), so plaintext items are unchanged. */
|
|
35422
|
-
envelope: external_exports.object({
|
|
35423
|
-
context: external_exports.lazy(() => EnvelopeSchema2).optional(),
|
|
35424
|
-
options: external_exports.lazy(() => EnvelopeSchema2).optional(),
|
|
35425
|
-
visuals: external_exports.lazy(() => EnvelopeSchema2).optional()
|
|
35426
|
-
}).optional(),
|
|
35427
|
-
/** E2EE: the agent's device X25519 public key to seal the user's answer BACK to (the
|
|
35428
|
-
* sender the phone replies to). Sourced server-side from this item's pairing credential.
|
|
35429
|
-
* Present only alongside `envelope`; the phone seals via sealAnswer(answer, this, id). */
|
|
35430
|
-
agentX25519: external_exports.string().optional(),
|
|
35431
32984
|
/** THE TARGET FACTS A CARD RENDERS (#1796 point 5, 2026-09-11): the Delivery it is a view of,
|
|
35432
32985
|
* that Delivery's kind, the request Entry, the Goals it answers for, the exact DecisionNeed (none
|
|
35433
32986
|
* for a request that asks nothing), whether its content is sealed, and that Goal's state. The
|
|
@@ -35525,13 +33078,6 @@ var UserSettingsSchema2 = external_exports.object({
|
|
|
35525
33078
|
* setting. Absent = a spoken time can't be landed, so the reminder rides the next
|
|
35526
33079
|
* call — honest about what we know. */
|
|
35527
33080
|
timezone: external_exports.string().min(1).max(64).optional(),
|
|
35528
|
-
/** Account E2EE state (text lane): 'off' (default) = today's plaintext; 'on' =
|
|
35529
|
-
* content is sealed end-to-end between the local agent and the phone. Like
|
|
35530
|
-
* voiceMode, OPTIONAL and NOT defaulted so a stale client PATCHing the full
|
|
35531
|
-
* settings object without it can't silently flip the account's E2EE state.
|
|
35532
|
-
* Absent = leave unchanged on write, 'off' on read (see store.ts). The demo
|
|
35533
|
-
* account is plaintext by construction and refuses any non-'off' value. */
|
|
35534
|
-
e2eeMode: external_exports.enum(["off", "on"]).optional(),
|
|
35535
33081
|
/** Rung-2 broker tuning (#381). Optional and NOT defaulted, same stale-client
|
|
35536
33082
|
* clobber guard as voiceMode: absent = leave unchanged on write. */
|
|
35537
33083
|
broker: BrokerTuningSchema2.optional()
|
|
@@ -35721,6 +33267,8 @@ var QueueItemSchema2 = external_exports.object({
|
|
|
35721
33267
|
blocked: external_exports.boolean().default(false),
|
|
35722
33268
|
/** Every decision need on it, open or settled — the page decides which to show. */
|
|
35723
33269
|
questions: external_exports.array(QueueQuestionSchema2).default([]),
|
|
33270
|
+
/** The repository or project identifier this Goal belongs to (#2280), null if untracked. */
|
|
33271
|
+
repo: external_exports.string().nullable().optional(),
|
|
35724
33272
|
createdAt: external_exports.string(),
|
|
35725
33273
|
updatedAt: external_exports.string().nullable().default(null)
|
|
35726
33274
|
});
|
|
@@ -35832,54 +33380,12 @@ var DeliveryConfigSchema2 = external_exports.object({
|
|
|
35832
33380
|
* carries credentials; only a `poll` registration can come back with null here. */
|
|
35833
33381
|
realtime: external_exports.object({ url: external_exports.string(), anonKey: external_exports.string() }).nullable()
|
|
35834
33382
|
});
|
|
35835
|
-
var EnvelopeRecipientSchema2 = external_exports.object({
|
|
35836
|
-
keyId: external_exports.string(),
|
|
35837
|
-
epk: external_exports.string(),
|
|
35838
|
-
wnonce: external_exports.string(),
|
|
35839
|
-
wrap: external_exports.string()
|
|
35840
|
-
});
|
|
35841
|
-
var EnvelopeHeaderSchema2 = external_exports.object({
|
|
35842
|
-
field: external_exports.enum(["context", "options", "visuals", "answer"]),
|
|
35843
|
-
kind: external_exports.string(),
|
|
35844
|
-
senderRole: external_exports.enum(["agent", "user"]),
|
|
35845
|
-
recipientKeyIds: external_exports.array(external_exports.string()),
|
|
35846
|
-
seq: external_exports.number().int().nonnegative()
|
|
35847
|
-
});
|
|
35848
|
-
var EnvelopeSchema2 = external_exports.object({
|
|
35849
|
-
v: external_exports.literal(1),
|
|
35850
|
-
alg: external_exports.literal("x25519-xsalsa20poly1305"),
|
|
35851
|
-
msgId: external_exports.string(),
|
|
35852
|
-
hdr: EnvelopeHeaderSchema2,
|
|
35853
|
-
recipients: external_exports.array(EnvelopeRecipientSchema2).min(1),
|
|
35854
|
-
nonce: external_exports.string(),
|
|
35855
|
-
ct: external_exports.string()
|
|
35856
|
-
});
|
|
35857
|
-
var SealedAnswerSchema2 = external_exports.object({
|
|
35858
|
-
ignored: external_exports.boolean(),
|
|
35859
|
-
envelope: EnvelopeSchema2
|
|
35860
|
-
});
|
|
35861
|
-
var DeviceCredentialSchema2 = external_exports.object({
|
|
35862
|
-
deviceId: external_exports.string(),
|
|
35863
|
-
kind: external_exports.enum(["phone", "web", "agent"]),
|
|
35864
|
-
x25519Pub: external_exports.string(),
|
|
35865
|
-
ed25519Pub: external_exports.string(),
|
|
35866
|
-
sig: external_exports.string()
|
|
35867
|
-
});
|
|
35868
|
-
var DeviceRosterSchema2 = external_exports.object({
|
|
35869
|
-
uikPub: external_exports.string(),
|
|
35870
|
-
devices: external_exports.array(DeviceCredentialSchema2)
|
|
35871
|
-
});
|
|
35872
33383
|
var WakeNudgeSchema2 = external_exports.object({
|
|
35873
33384
|
kind: external_exports.enum(["reply", "request", "callback"]),
|
|
35874
33385
|
notificationId: external_exports.string().optional(),
|
|
35875
33386
|
parentId: external_exports.string()
|
|
35876
33387
|
});
|
|
35877
33388
|
var PairingStatusSchema2 = external_exports.enum(["pending", "approved", "denied", "expired"]);
|
|
35878
|
-
var PairingRevealSchema2 = external_exports.object({
|
|
35879
|
-
x25519: external_exports.string(),
|
|
35880
|
-
ed25519: external_exports.string(),
|
|
35881
|
-
nonce: external_exports.string()
|
|
35882
|
-
});
|
|
35883
33389
|
var DeviceCodeSchema2 = external_exports.object({
|
|
35884
33390
|
device_code: external_exports.string(),
|
|
35885
33391
|
user_code: external_exports.string(),
|
|
@@ -35899,19 +33405,7 @@ var DeviceInfoSchema2 = external_exports.object({
|
|
|
35899
33405
|
* (seen live: PAIGY-5T, 2026-07-21). Remove once a newer binary is the floor. */
|
|
35900
33406
|
agent: external_exports.string().optional(),
|
|
35901
33407
|
device: external_exports.string().nullable(),
|
|
35902
|
-
status: PairingStatusSchema2
|
|
35903
|
-
proto: external_exports.string().nullable().optional(),
|
|
35904
|
-
agent_commitment: external_exports.string().nullable().optional(),
|
|
35905
|
-
// Ca
|
|
35906
|
-
agent_reveal: PairingRevealSchema2.nullable().optional(),
|
|
35907
|
-
// present once the agent reveals
|
|
35908
|
-
agent_credential: DeviceCredentialSchema2.nullable().optional(),
|
|
35909
|
-
// the phone's UIK-signed cred over the agent's keys — the agent fetches it here to finalizeE2ee
|
|
35910
|
-
// The phone's reveal + identity key, exposed here so a GATED agent (e2ee_mode='on', token
|
|
35911
|
-
// withheld until e2ee=true) can compute the SAS WITHOUT a token. Public keys — same safety
|
|
35912
|
-
// class as agent_reveal above. Present only once the phone reveals; null otherwise.
|
|
35913
|
-
phone_reveal: PairingRevealSchema2.nullable().optional(),
|
|
35914
|
-
uik_pub: external_exports.string().nullable().optional()
|
|
33408
|
+
status: PairingStatusSchema2
|
|
35915
33409
|
});
|
|
35916
33410
|
var DeviceTokenSchema2 = external_exports.object({
|
|
35917
33411
|
access_token: external_exports.string(),
|
|
@@ -35930,8 +33424,6 @@ var DeviceTokenSchema2 = external_exports.object({
|
|
|
35930
33424
|
* landed in the FIRST granted workspace and the agent rediscovered its own repo from
|
|
35931
33425
|
* the thread each time (host.ts, live catch 2026-08-06 — prompt-papered until now). */
|
|
35932
33426
|
workspace: external_exports.string().nullable().optional(),
|
|
35933
|
-
phone_reveal: PairingRevealSchema2.nullable().optional(),
|
|
35934
|
-
// present once the phone reveals
|
|
35935
33427
|
uik_pub: external_exports.string().nullable().optional()
|
|
35936
33428
|
});
|
|
35937
33429
|
var SupportRequestSchema2 = external_exports.object({
|
|
@@ -35953,13 +33445,6 @@ var NotificationFeedbackKindSchema2 = external_exports.enum([
|
|
|
35953
33445
|
"other"
|
|
35954
33446
|
// anything else — the note carries it.
|
|
35955
33447
|
]);
|
|
35956
|
-
var FeedbackResolutionSchema2 = external_exports.enum(["broker_fixed", "sent_to_agent"]);
|
|
35957
|
-
var FeedbackOutcomeSchema2 = external_exports.object({
|
|
35958
|
-
resolution: FeedbackResolutionSchema2,
|
|
35959
|
-
transform: TransformSchema2,
|
|
35960
|
-
message: external_exports.string(),
|
|
35961
|
-
childIds: external_exports.array(external_exports.string()).optional()
|
|
35962
|
-
});
|
|
35963
33448
|
|
|
35964
33449
|
// src/paigy/activity.ts
|
|
35965
33450
|
function shortenPaths(s) {
|
|
@@ -35985,14 +33470,32 @@ function sameTail(a, b) {
|
|
|
35985
33470
|
init_dist();
|
|
35986
33471
|
|
|
35987
33472
|
// src/paigy/conversation.ts
|
|
33473
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
33474
|
+
var HARNESS_INSTRUCTION = "You are running as an unattended background harness agent connected to your user through Paigy. The user is NOT at the terminal and cannot see text printed here. To ask questions, request approvals, or make decisions, use Paigy tools or end your turn with a clear question for the bridge to relay. When complete, provide a concise summary of what was accomplished.";
|
|
35988
33475
|
function endsWithQuestion(text) {
|
|
35989
33476
|
if (!text) return false;
|
|
35990
|
-
const
|
|
35991
|
-
if (!
|
|
35992
|
-
if (
|
|
33477
|
+
const trimmed = text.trim();
|
|
33478
|
+
if (!trimmed) return false;
|
|
33479
|
+
if (trimmed.endsWith("?")) return true;
|
|
33480
|
+
const lines2 = trimmed.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
33481
|
+
if (lines2.length === 0) return false;
|
|
33482
|
+
let lastNonListIdx = lines2.length - 1;
|
|
33483
|
+
while (lastNonListIdx >= 0) {
|
|
33484
|
+
const line = lines2[lastNonListIdx];
|
|
33485
|
+
if (line && /^[-*•\d.)]\s+/.test(line)) {
|
|
33486
|
+
lastNonListIdx--;
|
|
33487
|
+
} else {
|
|
33488
|
+
break;
|
|
33489
|
+
}
|
|
33490
|
+
}
|
|
33491
|
+
const promptLine = lastNonListIdx >= 0 ? lines2[lastNonListIdx] : lines2[lines2.length - 1];
|
|
33492
|
+
if (promptLine?.endsWith("?")) return true;
|
|
33493
|
+
const tail = lines2.slice(-3).join(" ").toLowerCase();
|
|
35993
33494
|
return [
|
|
35994
33495
|
/\b(let me know|which (one|would|do you)|do you want|should i|shall i)\b/,
|
|
35995
|
-
/\b(want me to|prefer|your call|up to you|confirm whether)\b
|
|
33496
|
+
/\b(want me to|prefer|your call|up to you|confirm whether)\b/,
|
|
33497
|
+
/\b(how would you like|how should we|what would you like|what should we)\b/,
|
|
33498
|
+
/\b(please choose|choose one|select one|how do you want)\b/
|
|
35996
33499
|
].some((re) => re.test(tail));
|
|
35997
33500
|
}
|
|
35998
33501
|
var POLL_MS = 5e3;
|
|
@@ -36010,17 +33513,34 @@ function unheard(brief, state) {
|
|
|
36010
33513
|
}
|
|
36011
33514
|
return words2;
|
|
36012
33515
|
}
|
|
36013
|
-
async function step(session, state, rail) {
|
|
33516
|
+
async function step(session, state, rail, opts) {
|
|
36014
33517
|
if (!state.goal) {
|
|
36015
33518
|
if (!state.resting) return;
|
|
36016
|
-
|
|
36017
|
-
if (!brief2.goalId || brief2.revision === void 0)
|
|
33519
|
+
let brief2 = await rail.claim();
|
|
33520
|
+
if (!brief2.goalId || brief2.revision === void 0) {
|
|
33521
|
+
if (opts?.initialPrompt?.trim()) {
|
|
33522
|
+
const prompt = opts.initialPrompt.trim();
|
|
33523
|
+
opts.initialPrompt = void 0;
|
|
33524
|
+
const admitted = await rail.create({ outcome: prompt, idempotencyKey: randomUUID4() });
|
|
33525
|
+
brief2 = await rail.claim();
|
|
33526
|
+
if (!brief2.goalId || brief2.revision === void 0) {
|
|
33527
|
+
state.goal = { id: admitted.goalId, revision: admitted.revision };
|
|
33528
|
+
if (checkCallOnDone(prompt)) state.callOnDone = true;
|
|
33529
|
+
send2(session, state, [HARNESS_INSTRUCTION, prompt].join("\n\n"));
|
|
33530
|
+
return;
|
|
33531
|
+
}
|
|
33532
|
+
} else {
|
|
33533
|
+
return;
|
|
33534
|
+
}
|
|
33535
|
+
}
|
|
36018
33536
|
unheard(brief2, state);
|
|
36019
33537
|
if (ended(brief2.state)) await rail.update(brief2.goalId, { revision: brief2.revision, changes: { reviewed: true }, reason: "Typed into the session." });
|
|
36020
33538
|
else state.goal = { id: brief2.goalId, revision: brief2.revision };
|
|
36021
33539
|
const outcome = brief2.outcome?.trim() ?? "";
|
|
36022
33540
|
const said = (brief2.entries ?? []).map((e) => entryWords(e).trim()).filter((w) => w && w.toLowerCase() !== outcome.toLowerCase());
|
|
36023
|
-
|
|
33541
|
+
const fullText = [outcome, ...said].filter(Boolean).join("\n\n");
|
|
33542
|
+
if (checkCallOnDone(fullText)) state.callOnDone = true;
|
|
33543
|
+
send2(session, state, [HARNESS_INSTRUCTION, fullText].filter(Boolean).join("\n\n"));
|
|
36024
33544
|
return;
|
|
36025
33545
|
}
|
|
36026
33546
|
const brief = await rail.read(state.goal.id);
|
|
@@ -36039,16 +33559,21 @@ async function step(session, state, rail) {
|
|
|
36039
33559
|
}
|
|
36040
33560
|
if (state.asks?.size || !state.resting) return;
|
|
36041
33561
|
const words2 = unheard(brief, state);
|
|
36042
|
-
if (words2.length)
|
|
33562
|
+
if (words2.length) {
|
|
33563
|
+
const text = words2.join("\n\n");
|
|
33564
|
+
if (checkCallOnDone(text)) state.callOnDone = true;
|
|
33565
|
+
send2(session, state, text);
|
|
33566
|
+
}
|
|
36043
33567
|
}
|
|
36044
33568
|
function send2(session, state, text) {
|
|
36045
33569
|
state.resting = false;
|
|
36046
33570
|
session.send(text);
|
|
36047
33571
|
}
|
|
36048
33572
|
async function pump(session, state, rail, opts) {
|
|
33573
|
+
const promptRef = opts.initialPrompt ? { initialPrompt: opts.initialPrompt } : void 0;
|
|
36049
33574
|
for (; ; ) {
|
|
36050
33575
|
try {
|
|
36051
|
-
await step(session, state, rail);
|
|
33576
|
+
await step(session, state, rail, promptRef);
|
|
36052
33577
|
} catch {
|
|
36053
33578
|
}
|
|
36054
33579
|
if (!await opts.onIdle()) return;
|
|
@@ -36056,25 +33581,6 @@ async function pump(session, state, rail, opts) {
|
|
|
36056
33581
|
}
|
|
36057
33582
|
}
|
|
36058
33583
|
|
|
36059
|
-
// src/paigy/level.ts
|
|
36060
|
-
var DESTRUCTIVE = [
|
|
36061
|
-
/\brm\s+-[a-z]*[rf]/,
|
|
36062
|
-
// rm -rf, rm -f
|
|
36063
|
-
/\bgit\s+push\b.*(--force|-f\b)/,
|
|
36064
|
-
/\bgit\s+reset\s+--hard/,
|
|
36065
|
-
/\bgit\s+clean\s+-[a-z]*f/,
|
|
36066
|
-
/\bdrop\s+(table|database|schema)\b/i,
|
|
36067
|
-
/\btruncate\s+table\b/i,
|
|
36068
|
-
/\bdd\s+if=/,
|
|
36069
|
-
/\bmkfs\b/,
|
|
36070
|
-
/\b(shutdown|reboot)\b/,
|
|
36071
|
-
/:\s*>\s*\/dev\/sd/
|
|
36072
|
-
// writing over a raw device
|
|
36073
|
-
];
|
|
36074
|
-
function isDestructive(summary) {
|
|
36075
|
-
return DESTRUCTIVE.some((re) => re.test(summary));
|
|
36076
|
-
}
|
|
36077
|
-
|
|
36078
33584
|
// src/paigy/bridge.ts
|
|
36079
33585
|
function railFor(opts) {
|
|
36080
33586
|
return {
|
|
@@ -36082,7 +33588,8 @@ function railFor(opts) {
|
|
|
36082
33588
|
read: (goalId) => getGoal(goalId, opts),
|
|
36083
33589
|
update: (goalId, input) => updateGoal(goalId, input, opts),
|
|
36084
33590
|
// One read and back: the pump owns the waiting, so a Call must not hold a window here.
|
|
36085
|
-
contact: (input) => contact(input, { ...opts, waits: false })
|
|
33591
|
+
contact: (input) => contact(input, { ...opts, waits: false }),
|
|
33592
|
+
create: (input) => createGoal(input, opts)
|
|
36086
33593
|
};
|
|
36087
33594
|
}
|
|
36088
33595
|
function cancelAsks(state) {
|
|
@@ -36119,11 +33626,9 @@ async function ask(state, rail, input) {
|
|
|
36119
33626
|
if (!state.goal) return null;
|
|
36120
33627
|
try {
|
|
36121
33628
|
const sent = await rail.contact({
|
|
36122
|
-
|
|
36123
|
-
ask: input.ask,
|
|
33629
|
+
asks: [{ ask: input.ask, parentId: state.goal.id, ...input.options ? { options: input.options } : {} }],
|
|
36124
33630
|
waiting: "hard",
|
|
36125
|
-
channel: input.call ? "call" : "notification"
|
|
36126
|
-
...input.options ? { options: input.options } : {}
|
|
33631
|
+
channel: input.call ? "call" : "notification"
|
|
36127
33632
|
});
|
|
36128
33633
|
const entryId = sent.requestEntryIds[0];
|
|
36129
33634
|
if (!entryId) return null;
|
|
@@ -36133,37 +33638,87 @@ async function ask(state, rail, input) {
|
|
|
36133
33638
|
return null;
|
|
36134
33639
|
}
|
|
36135
33640
|
}
|
|
33641
|
+
function checkCallOnDone(text) {
|
|
33642
|
+
if (!text) return false;
|
|
33643
|
+
return /\b(call|ring|phone)\b.*\b(done|finish(ed)?|complete(d)?)\b/i.test(text) || /\b(when|if|once)\b.*\b(done|finish(ed)?|complete(d)?)\b.*\b(call|ring|phone)\b/i.test(text) || /\bcall\s+(me|us)\b/i.test(text);
|
|
33644
|
+
}
|
|
33645
|
+
function parseQuestionOptions(text) {
|
|
33646
|
+
if (!text) return { question: "" };
|
|
33647
|
+
const trimmed = text.trim();
|
|
33648
|
+
const lines2 = trimmed.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
33649
|
+
const optionLines = [];
|
|
33650
|
+
const questionLines = [];
|
|
33651
|
+
for (const line of lines2) {
|
|
33652
|
+
const bulletMatch = line.match(/^[-*•]\s+(.*)$/) ?? line.match(/^\d+[.)]\s+(.*)$/);
|
|
33653
|
+
if (bulletMatch) {
|
|
33654
|
+
optionLines.push(bulletMatch[1].trim());
|
|
33655
|
+
} else {
|
|
33656
|
+
questionLines.push(line);
|
|
33657
|
+
}
|
|
33658
|
+
}
|
|
33659
|
+
if (optionLines.length >= 2 && optionLines.length <= 6) {
|
|
33660
|
+
return {
|
|
33661
|
+
question: questionLines.join("\n\n").trim() || trimmed,
|
|
33662
|
+
options: optionLines.map((raw) => {
|
|
33663
|
+
const colonSplit = raw.match(/^([^:—–-]+)\s*[:—–-]\s*(.+)$/);
|
|
33664
|
+
const parenSplit = raw.match(/^([^(]+)\s*\(([^)]+)\)$/);
|
|
33665
|
+
if (colonSplit && colonSplit[1] && colonSplit[2]) {
|
|
33666
|
+
return { label: colonSplit[1].trim().slice(0, 100), hint: colonSplit[2].trim().slice(0, 250) };
|
|
33667
|
+
}
|
|
33668
|
+
if (parenSplit && parenSplit[1] && parenSplit[2]) {
|
|
33669
|
+
return { label: parenSplit[1].trim().slice(0, 100), hint: parenSplit[2].trim().slice(0, 250) };
|
|
33670
|
+
}
|
|
33671
|
+
return { label: raw.slice(0, 1e3) };
|
|
33672
|
+
})
|
|
33673
|
+
};
|
|
33674
|
+
}
|
|
33675
|
+
return { question: trimmed };
|
|
33676
|
+
}
|
|
36136
33677
|
async function askPermission(event, state, rail) {
|
|
36137
33678
|
return decisionFrom(await ask(state, rail, {
|
|
36138
33679
|
ask: [`The agent is blocked waiting to run: ${event.summary}`, ...event.reason ? [event.reason] : []].join("\n\n"),
|
|
36139
|
-
options: [
|
|
36140
|
-
|
|
33680
|
+
options: [
|
|
33681
|
+
{ label: ALLOW, hint: "Permits the agent to run this command" },
|
|
33682
|
+
{ label: "Deny", hint: "Blocks execution of this command" }
|
|
33683
|
+
],
|
|
33684
|
+
call: true
|
|
36141
33685
|
}));
|
|
36142
33686
|
}
|
|
36143
|
-
async function askQuestion(question, state, rail) {
|
|
36144
|
-
return wordsOf(await ask(state, rail, {
|
|
33687
|
+
async function askQuestion(question, state, rail, opts) {
|
|
33688
|
+
return wordsOf(await ask(state, rail, {
|
|
33689
|
+
ask: question,
|
|
33690
|
+
call: opts?.call ?? true,
|
|
33691
|
+
options: opts?.options
|
|
33692
|
+
}));
|
|
36145
33693
|
}
|
|
36146
|
-
async function finish(result, state, rail) {
|
|
33694
|
+
async function finish(result, state, rail, opts) {
|
|
36147
33695
|
const goal = state.goal;
|
|
36148
33696
|
if (!goal) return;
|
|
36149
33697
|
state.goal = void 0;
|
|
36150
33698
|
const report = result?.trim() || "Done.";
|
|
33699
|
+
const channel = opts?.call || state.callOnDone ? "call" : "notification";
|
|
36151
33700
|
try {
|
|
36152
|
-
await rail.contact({
|
|
33701
|
+
await rail.contact({ asks: [{ ask: report, parentId: goal.id }], waiting: "none", channel });
|
|
36153
33702
|
const { revision } = await rail.read(goal.id);
|
|
36154
33703
|
await rail.update(goal.id, { revision: revision ?? goal.revision, changes: { state: "done", progress: report.slice(0, 1e4) }, reason: "The agent finished its turn without asking anything." });
|
|
36155
|
-
} catch {
|
|
33704
|
+
} catch (error) {
|
|
33705
|
+
opts?.log?.(`\u26A0 finish contact failed: ${error.message}`);
|
|
36156
33706
|
}
|
|
36157
33707
|
}
|
|
36158
|
-
async function afterTurn(event, state, rail) {
|
|
33708
|
+
async function afterTurn(event, state, rail, opts) {
|
|
36159
33709
|
if (!event.failed && !endsWithQuestion(event.result)) {
|
|
36160
|
-
await finish(event.result, state, rail);
|
|
33710
|
+
await finish(event.result, state, rail, opts);
|
|
36161
33711
|
state.resting = true;
|
|
36162
33712
|
return null;
|
|
36163
33713
|
}
|
|
36164
|
-
const
|
|
33714
|
+
const rawText = event.failed ? `The agent stopped without finishing.
|
|
36165
33715
|
|
|
36166
|
-
${event.result?.trim() || "No result reported."}` : event.result ?? ""
|
|
33716
|
+
${event.result?.trim() || "No result reported."}` : event.result ?? "";
|
|
33717
|
+
const parsed = parseQuestionOptions(rawText);
|
|
33718
|
+
const reply = await askQuestion(parsed.question, state, rail, {
|
|
33719
|
+
call: true,
|
|
33720
|
+
options: parsed.options
|
|
33721
|
+
});
|
|
36167
33722
|
if (!reply) state.resting = true;
|
|
36168
33723
|
return reply;
|
|
36169
33724
|
}
|
|
@@ -36210,7 +33765,7 @@ function runHarness(opts) {
|
|
|
36210
33765
|
return;
|
|
36211
33766
|
}
|
|
36212
33767
|
}
|
|
36213
|
-
const reply = await afterTurn(event, state, rail);
|
|
33768
|
+
const reply = await afterTurn(event, state, rail, { log: opts.log });
|
|
36214
33769
|
if (reply && session && running) {
|
|
36215
33770
|
opts.log(`you: ${reply.split("\n")[0] ?? ""}`);
|
|
36216
33771
|
session.send(reply);
|
|
@@ -36227,11 +33782,7 @@ function runHarness(opts) {
|
|
|
36227
33782
|
...opts.onExit ? { onExit: opts.onExit } : {},
|
|
36228
33783
|
onEvent: (event) => void handle(event).catch((err) => opts.log(`\u26A0 ${err.message}`))
|
|
36229
33784
|
});
|
|
36230
|
-
|
|
36231
|
-
state.resting = false;
|
|
36232
|
-
session.send(opts.prompt);
|
|
36233
|
-
}
|
|
36234
|
-
void pump(session, state, rail, { onIdle: () => running }).catch(
|
|
33785
|
+
void pump(session, state, rail, { onIdle: () => running, initialPrompt: opts.prompt }).catch(
|
|
36235
33786
|
(e) => opts.log(`\u26A0 conversation loop stopped: ${e.message}`)
|
|
36236
33787
|
);
|
|
36237
33788
|
opts.log(`\u25B6 started ${opts.harness} in ${opts.cwd} (${opts.mode} mode)`);
|
|
@@ -36255,12 +33806,12 @@ function runHarness(opts) {
|
|
|
36255
33806
|
// src/host.ts
|
|
36256
33807
|
init_dist();
|
|
36257
33808
|
init_catalog();
|
|
36258
|
-
import { readFileSync as
|
|
33809
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
36259
33810
|
import { homedir as homedir6 } from "os";
|
|
36260
33811
|
import { join as join6 } from "path";
|
|
36261
33812
|
|
|
36262
33813
|
// src/workspaces.ts
|
|
36263
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as
|
|
33814
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
36264
33815
|
import { dirname as dirname2, join as join3, resolve as resolve2 } from "path";
|
|
36265
33816
|
import { homedir as homedir4 } from "os";
|
|
36266
33817
|
function workspacesFile() {
|
|
@@ -36268,7 +33819,7 @@ function workspacesFile() {
|
|
|
36268
33819
|
}
|
|
36269
33820
|
function listWorkspaces(deps) {
|
|
36270
33821
|
try {
|
|
36271
|
-
const parsed = JSON.parse(
|
|
33822
|
+
const parsed = JSON.parse(readFileSync3(deps.file, "utf8"));
|
|
36272
33823
|
return Array.isArray(parsed) ? parsed.filter((w) => typeof w === "string") : [];
|
|
36273
33824
|
} catch {
|
|
36274
33825
|
return [];
|
|
@@ -36368,9 +33919,13 @@ function newer(latest, current) {
|
|
|
36368
33919
|
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];
|
|
36369
33920
|
return false;
|
|
36370
33921
|
}
|
|
33922
|
+
var WAIT_CAP_MS = 6 * 36e5;
|
|
36371
33923
|
function updateAction(o) {
|
|
36372
33924
|
if (!o.service || !o.latest || o.latest === o.failed || !newer(o.latest, o.current)) return "none";
|
|
36373
|
-
|
|
33925
|
+
if (o.sessions <= 0) return "install";
|
|
33926
|
+
const working = o.working ?? o.sessions;
|
|
33927
|
+
if (working > 0) return "wait";
|
|
33928
|
+
return (o.waited ?? 0) >= WAIT_CAP_MS ? "install" : "wait";
|
|
36374
33929
|
}
|
|
36375
33930
|
async function latestVersion() {
|
|
36376
33931
|
const res = await fetch(REGISTRY, { signal: AbortSignal.timeout(1e4) });
|
|
@@ -36389,6 +33944,7 @@ function selfUpdater(deps) {
|
|
|
36389
33944
|
let checkedAt = -Infinity;
|
|
36390
33945
|
let failed;
|
|
36391
33946
|
let waiting = false;
|
|
33947
|
+
let waitingSince = null;
|
|
36392
33948
|
return async () => {
|
|
36393
33949
|
if (!service) return;
|
|
36394
33950
|
const now = (deps.now ?? Date.now)();
|
|
@@ -36396,9 +33952,25 @@ function selfUpdater(deps) {
|
|
|
36396
33952
|
checkedAt = now;
|
|
36397
33953
|
latest = await (deps.latest ?? latestVersion)().catch(() => latest);
|
|
36398
33954
|
}
|
|
36399
|
-
const
|
|
36400
|
-
|
|
33955
|
+
const sessions = deps.sessions();
|
|
33956
|
+
const working = deps.working?.();
|
|
33957
|
+
if (latest && newer(latest, VERSION) && latest !== failed && waitingSince === null) waitingSince = now;
|
|
33958
|
+
const action = updateAction({
|
|
33959
|
+
current: VERSION,
|
|
33960
|
+
latest,
|
|
33961
|
+
service,
|
|
33962
|
+
sessions,
|
|
33963
|
+
failed,
|
|
33964
|
+
...working === void 0 ? {} : { working },
|
|
33965
|
+
waited: waitingSince === null ? 0 : now - waitingSince
|
|
33966
|
+
});
|
|
33967
|
+
if (action === "wait" && !waiting) {
|
|
33968
|
+
deps.log(working ? `\u21E1 @paigy/harness ${latest} is out \u2014 updating once the turn in flight finishes` : `\u21E1 @paigy/harness ${latest} is out \u2014 updating once no session is running (at most ${Math.round(WAIT_CAP_MS / 36e5)}h)`);
|
|
33969
|
+
}
|
|
36401
33970
|
waiting = action === "wait";
|
|
33971
|
+
if (action === "install" && sessions > 0) {
|
|
33972
|
+
deps.log(`\u21E1 @paigy/harness ${latest} is out and ${sessions} resting session(s) have held it for ${Math.round((now - (waitingSince ?? now)) / 36e5)}h \u2014 restarting over them`);
|
|
33973
|
+
}
|
|
36402
33974
|
if (action !== "install" || !latest) return;
|
|
36403
33975
|
try {
|
|
36404
33976
|
await (deps.install ?? install)(latest);
|
|
@@ -36443,7 +34015,12 @@ function startHost(opts) {
|
|
|
36443
34015
|
}
|
|
36444
34016
|
}
|
|
36445
34017
|
};
|
|
36446
|
-
const update = selfUpdater({
|
|
34018
|
+
const update = selfUpdater({
|
|
34019
|
+
sessions: () => runs.size,
|
|
34020
|
+
// A turn in flight blocks the update; a session merely standing by does not hold it forever.
|
|
34021
|
+
working: () => [...runs.values()].filter((r) => r.run.working()).length,
|
|
34022
|
+
log: opts.log
|
|
34023
|
+
});
|
|
36447
34024
|
const beat = () => {
|
|
36448
34025
|
void refreshIdentities();
|
|
36449
34026
|
void update().catch(() => {
|
|
@@ -36471,6 +34048,7 @@ function startHost(opts) {
|
|
|
36471
34048
|
mode: "bypass",
|
|
36472
34049
|
prompt: "",
|
|
36473
34050
|
token: spec.token,
|
|
34051
|
+
resume: spec.sessionId,
|
|
36474
34052
|
onExit: () => {
|
|
36475
34053
|
runs.delete(key);
|
|
36476
34054
|
opts.log(`\u2716 ${label} ended`);
|
|
@@ -36745,7 +34323,7 @@ function printConnectLines(link, userCode, enter) {
|
|
|
36745
34323
|
}
|
|
36746
34324
|
async function pairThisMachine() {
|
|
36747
34325
|
const host = hostname().replace(/\.local$/, "");
|
|
36748
|
-
const code = await requestCode(host,
|
|
34326
|
+
const code = await requestCode(host, host);
|
|
36749
34327
|
const link = code.verification_uri_complete;
|
|
36750
34328
|
console.log(await import_qrcode.default.toString(link, { type: "terminal", small: true }));
|
|
36751
34329
|
printConnectLines(link, code.user_code, !!process.stdin.isTTY);
|
|
@@ -36770,7 +34348,7 @@ async function pairThisMachine() {
|
|
|
36770
34348
|
function forwardCodexThreadId() {
|
|
36771
34349
|
const cfg = join7(process.env.CODEX_HOME || join7(homedir8(), ".codex"), "config.toml");
|
|
36772
34350
|
if (!existsSync5(cfg)) return;
|
|
36773
|
-
const text =
|
|
34351
|
+
const text = readFileSync5(cfg, "utf8");
|
|
36774
34352
|
const head = "[mcp_servers.paigy]\n";
|
|
36775
34353
|
const at = text.indexOf(head);
|
|
36776
34354
|
if (at < 0) return;
|
|
@@ -36913,7 +34491,7 @@ async function main() {
|
|
|
36913
34491
|
try {
|
|
36914
34492
|
const settings = join7(homedir8(), ".claude", "settings.json");
|
|
36915
34493
|
if (which("claude") && existsSync5(settings)) {
|
|
36916
|
-
const cfg = JSON.parse(
|
|
34494
|
+
const cfg = JSON.parse(readFileSync5(settings, "utf8"));
|
|
36917
34495
|
if (!cfg["statusLine"]) {
|
|
36918
34496
|
cfg["statusLine"] = { type: "command", command: "npx -y -p @paigy/mcp@latest paigy-statusline" };
|
|
36919
34497
|
writeFileSync4(settings, JSON.stringify(cfg, null, 2));
|
|
@@ -36987,7 +34565,7 @@ async function main() {
|
|
|
36987
34565
|
process.exit(1);
|
|
36988
34566
|
}
|
|
36989
34567
|
if (parsed.handoff) {
|
|
36990
|
-
const slot =
|
|
34568
|
+
const slot = agentName();
|
|
36991
34569
|
if (!readToken(slot)) {
|
|
36992
34570
|
console.error(`This terminal holds no Paigy identity (slot "${slot}" is empty) \u2014 pair or hatch first.`);
|
|
36993
34571
|
process.exit(1);
|