@rex0220/formula-authoring-tools 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/cli.mjs +74 -19
- package/dist/core.mjs +1403 -38
- package/dist/eval-worker.mjs +42 -14
- package/dist/types/commands/save.d.ts +86 -0
- package/dist/types/commands/take.d.ts +18 -0
- package/dist/types/commit-file.d.ts +38 -0
- package/dist/types/connections.d.ts +106 -0
- package/dist/types/core.d.ts +21 -13
- package/dist/types/engine.d.ts +4 -0
- package/dist/types/permission-error.d.ts +3 -0
- package/dist/types/permission.d.ts +10 -0
- package/dist/types/worker/eval-job.d.ts +24 -0
- package/dist/types/worker/eval-run.d.ts +11 -1
- package/dist/types/worker/run.d.ts +11 -3
- package/dist/types/workspace.d.ts +126 -0
- package/package.json +2 -1
package/dist/eval-worker.mjs
CHANGED
|
@@ -93,7 +93,7 @@ function devMeta() {
|
|
|
93
93
|
return { toolsVersion: pkg.version, pluginId: FORMULA_PLUGIN_ID, minPluginVersion: MIN_PLUGIN_VERSION, supportedApiVersions: [...SUPPORTED_API_VERSIONS], commit: gitCommit(AUTHORING_ROOT), builtAt: "", mode: "dev" };
|
|
94
94
|
}
|
|
95
95
|
function toolsMeta() {
|
|
96
|
-
if (true) return JSON.parse('{"toolsVersion":"0.1
|
|
96
|
+
if (true) return JSON.parse('{"toolsVersion":"0.2.1","pluginId":"dhgihghfgfmibkdldkeibboabfnmdpke","minPluginVersion":101,"supportedApiVersions":[1],"commit":"f2e46ef","builtAt":"2026-10-18T03:55:45.474Z","mode":"build"}');
|
|
97
97
|
return devMeta();
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -326,6 +326,8 @@ var DEFAULT_USERS = {
|
|
|
326
326
|
};
|
|
327
327
|
|
|
328
328
|
// src/users/index.ts
|
|
329
|
+
var UsersDataError = class extends Error {
|
|
330
|
+
};
|
|
329
331
|
function buildUsersInfo(src) {
|
|
330
332
|
const t = { users: [], organizations: [], groups: [], userCodes: {}, orgCodes: {}, groupCodes: {}, userIds: {}, orgIds: {}, groupIds: {} };
|
|
331
333
|
const orgsOf = {};
|
|
@@ -362,6 +364,9 @@ function defaultUsersInfo() {
|
|
|
362
364
|
}
|
|
363
365
|
|
|
364
366
|
// src/engine.ts
|
|
367
|
+
function momentFileOf(opt) {
|
|
368
|
+
return opt.vendorDir ? path3.join(opt.vendorDir, path3.basename(MOMENT_FILE)) : MOMENT_FILE;
|
|
369
|
+
}
|
|
365
370
|
var DEFAULT_CONTEXT_BASE_URL = "https://example.cybozu.com";
|
|
366
371
|
var SENTINEL_USER = { id: "0", code: "__sentinel__", name: "", email: "", timezone: "Asia/Tokyo", language: "ja", isGuest: false };
|
|
367
372
|
var loaded = null;
|
|
@@ -461,15 +466,16 @@ async function loadOnce(opt) {
|
|
|
461
466
|
}
|
|
462
467
|
if (!src.api) throw new PluginZipError(`計算式プラグインの zip に ${API_ENTRY} が無い(Ver.${MIN_PLUGIN_VERSION} 以降の zip が要る): ${src.from}`, "no-api", known);
|
|
463
468
|
if (!src.decimal) warnings.push(`zip に ${DECIMAL_ENTRY} が無い(べき乗の小数の指数がエラーになる)`);
|
|
464
|
-
|
|
469
|
+
const momentFile = momentFileOf(opt);
|
|
470
|
+
if (!existsSync(momentFile)) throw new Error(`moment が無い: ${momentFile}(tools の npm install 時に取る。手で取るなら npm run vendor)`);
|
|
465
471
|
try {
|
|
466
|
-
return await startEngine({ ...src, api: src.api }, known, warnings, stamp);
|
|
472
|
+
return await startEngine({ ...src, api: src.api }, known, warnings, stamp, momentFile);
|
|
467
473
|
} catch (e) {
|
|
468
474
|
poisoned = { code: e instanceof PluginZipError ? e.code : "unexpected", info: e instanceof PluginZipError ? e.info : known };
|
|
469
475
|
throw e;
|
|
470
476
|
}
|
|
471
477
|
}
|
|
472
|
-
async function startEngine(src, known, warnings, stamp) {
|
|
478
|
+
async function startEngine(src, known, warnings, stamp, momentFile) {
|
|
473
479
|
const g = globalThis;
|
|
474
480
|
const { Window } = await import("happy-dom");
|
|
475
481
|
const ctx = {
|
|
@@ -545,7 +551,7 @@ async function startEngine(src, known, warnings, stamp) {
|
|
|
545
551
|
throw new PluginZipError(`計算式プラグインの zip のコード(${entry})を実行できない: ${e instanceof Error ? e.message : String(e)}`, "engine-unreadable", known);
|
|
546
552
|
}
|
|
547
553
|
};
|
|
548
|
-
runScript(readFileSync3(
|
|
554
|
+
runScript(readFileSync3(momentFile, "utf8"), momentFile);
|
|
549
555
|
runScript(src.momentTimezone, `${src.from}!${MOMENT_TZ_ENTRY}`, MOMENT_TZ_ENTRY);
|
|
550
556
|
runScript(src.bignumber, `${src.from}!${BIGNUMBER_ENTRY}`, BIGNUMBER_ENTRY);
|
|
551
557
|
if (src.decimal) runScript(src.decimal, `${src.from}!${DECIMAL_ENTRY}`, DECIMAL_ENTRY);
|
|
@@ -735,6 +741,8 @@ var ROW_SOURCE_KEYS = ["fieldcode", "state", "formulaSet", "edit", "hide", "rank
|
|
|
735
741
|
|
|
736
742
|
// src/normalize/policy.ts
|
|
737
743
|
import path4 from "node:path";
|
|
744
|
+
var PolicyError = class extends Error {
|
|
745
|
+
};
|
|
738
746
|
var POLICY_FILE = path4.join("policy", "authoring-policy.json");
|
|
739
747
|
var MAX_POLICY_BYTES = 64 * 1024;
|
|
740
748
|
var DEFAULT_POLICY = { allowFunctions: [], allowMiscChanges: false };
|
|
@@ -1258,8 +1266,24 @@ function calcSettings(input) {
|
|
|
1258
1266
|
}
|
|
1259
1267
|
|
|
1260
1268
|
// src/worker/eval-run.ts
|
|
1269
|
+
function classifyEvalError(e) {
|
|
1270
|
+
const message = String(e?.message ?? e);
|
|
1271
|
+
if (e instanceof InputError) return { kind: "input", name: "InputError", message };
|
|
1272
|
+
if (e instanceof PluginZipError) return { kind: "zip", name: "PluginZipError", message, code: e.code };
|
|
1273
|
+
if (e instanceof UsersDataError) return { kind: "users", name: "UsersDataError", message };
|
|
1274
|
+
if (e instanceof PolicyError) return { kind: "policy", name: "PolicyError", message };
|
|
1275
|
+
return { kind: "other", name: builtinErrorName(e), message };
|
|
1276
|
+
}
|
|
1277
|
+
function builtinErrorName(e) {
|
|
1278
|
+
if (e instanceof TypeError) return "TypeError";
|
|
1279
|
+
if (e instanceof RangeError) return "RangeError";
|
|
1280
|
+
if (e instanceof ReferenceError) return "ReferenceError";
|
|
1281
|
+
if (e instanceof SyntaxError) return "SyntaxError";
|
|
1282
|
+
if (e instanceof URIError) return "URIError";
|
|
1283
|
+
return "Error";
|
|
1284
|
+
}
|
|
1261
1285
|
async function runEvalJob(job) {
|
|
1262
|
-
const engine = await loadEngine({ pluginZip: job.pluginZip, devPluginDir: job.devPluginDir, mode: job.mode });
|
|
1286
|
+
const engine = await loadEngine({ pluginZip: job.pluginZip, devPluginDir: job.devPluginDir, mode: job.mode, vendorDir: job.vendorDir });
|
|
1263
1287
|
if (job.baseUrl) engine.setContext({ baseUrl: job.baseUrl });
|
|
1264
1288
|
const usersInfo = buildUsersInfo(job.usersSource);
|
|
1265
1289
|
const usersLabel = job.usersOrigin.kind === "file" ? job.usersOrigin.file : "既定のテストデータ(架空)";
|
|
@@ -1276,7 +1300,16 @@ async function runEvalJob(job) {
|
|
|
1276
1300
|
usersOrigin: job.usersOrigin
|
|
1277
1301
|
});
|
|
1278
1302
|
const outcome = {
|
|
1279
|
-
normalize: {
|
|
1303
|
+
normalize: {
|
|
1304
|
+
summary: res.summary,
|
|
1305
|
+
hasErrors: res.findings.hasErrors,
|
|
1306
|
+
warnings: res.findings.count("warning"),
|
|
1307
|
+
findings: [...res.findings.items],
|
|
1308
|
+
output: res.output,
|
|
1309
|
+
checkDiffs: res.checkDiffs,
|
|
1310
|
+
appId: res.appId,
|
|
1311
|
+
size: res.size
|
|
1312
|
+
},
|
|
1280
1313
|
engineWarnings: [...engine.warnings]
|
|
1281
1314
|
};
|
|
1282
1315
|
if (job.kind === "calc" && job.calc && !res.findings.hasErrors) {
|
|
@@ -1294,7 +1327,7 @@ async function runEvalJob(job) {
|
|
|
1294
1327
|
usersInfo,
|
|
1295
1328
|
usersOrigin: job.usersOrigin
|
|
1296
1329
|
});
|
|
1297
|
-
outcome.calc = { text: r.text, failed: r.records.some((x) => x.errors.length > 0 || x.failed) };
|
|
1330
|
+
outcome.calc = { text: r.text, failed: r.records.some((x) => x.errors.length > 0 || x.failed), records: r.records, contextLine: r.contextLine, notice: r.notice, summary: r.summary };
|
|
1298
1331
|
}
|
|
1299
1332
|
return outcome;
|
|
1300
1333
|
}
|
|
@@ -1303,9 +1336,4 @@ async function runEvalJob(job) {
|
|
|
1303
1336
|
var post = (m) => {
|
|
1304
1337
|
parentPort?.postMessage(m);
|
|
1305
1338
|
};
|
|
1306
|
-
runEvalJob(workerData).then((outcome) => post({ ok: true, outcome })).catch((e) => {
|
|
1307
|
-
const err = e;
|
|
1308
|
-
const own = err?.name && err.name !== "Error" ? err.name : void 0;
|
|
1309
|
-
const name = own ?? err?.constructor?.name ?? "Error";
|
|
1310
|
-
post({ ok: false, error: { name: String(name), message: String(err?.message ?? e), ...err?.code ? { code: String(err.code) } : {} } });
|
|
1311
|
-
});
|
|
1339
|
+
runEvalJob(workerData).then((outcome) => post({ ok: true, outcome })).catch((e) => post({ ok: false, error: classifyEvalError(e) }));
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type Lang } from "../normalize/model.ts";
|
|
2
|
+
import type { Policy } from "../normalize/policy.ts";
|
|
3
|
+
import type { Finding } from "../normalize/findings.ts";
|
|
4
|
+
import { type WorkspaceMode } from "../workspace.ts";
|
|
5
|
+
import { ConnectionError } from "../connections.ts";
|
|
6
|
+
import { type UsersOrigin, type UsersSource } from "../users/index.ts";
|
|
7
|
+
import { type FieldChange } from "./diff.ts";
|
|
8
|
+
import { type RunOptions } from "../worker/run.ts";
|
|
9
|
+
export type SaveStatus = "ok" | "invalid" | "conflict" | "denied" | "failed";
|
|
10
|
+
export interface SaveResult {
|
|
11
|
+
status: SaveStatus;
|
|
12
|
+
/** 作業フォルダーからの相対パス(区切りは /) */
|
|
13
|
+
path: string;
|
|
14
|
+
/** 確定したファイルの digest(sha256。ok のとき) */
|
|
15
|
+
digest?: string;
|
|
16
|
+
findings: Finding[];
|
|
17
|
+
/** normalize の要約(検査まで進んだとき) */
|
|
18
|
+
summary?: string;
|
|
19
|
+
/** updateFields: 前の内容と確定した内容の差(項目ごと。affectsRecords = 既存レコードの値に影響する) */
|
|
20
|
+
diff?: {
|
|
21
|
+
fields: FieldChange[];
|
|
22
|
+
common: string[];
|
|
23
|
+
};
|
|
24
|
+
/** status が ok でないときの理由(決まった文) */
|
|
25
|
+
message?: string;
|
|
26
|
+
/** status が ok でないときの誤りの種類(ConflictError、PermissionError、PathError、InputError、NormalizeError、接続の誤りの code など。想定外の失敗は Error) */
|
|
27
|
+
code?: string;
|
|
28
|
+
/** code が PluginZipError のときの、zip の誤りの種類(MCP が種類ごとの決まった文にする) */
|
|
29
|
+
zipCode?: string;
|
|
30
|
+
/** ok だが、確定の後に一時ファイルかロックを消せなかった(確定はしている。利用者に伝えて消してもらう) */
|
|
31
|
+
cleanup?: string[];
|
|
32
|
+
}
|
|
33
|
+
/** 評価(normalize)の読み込み元(Worker に渡す。中核は環境変数を読まない) */
|
|
34
|
+
export interface EvalSource {
|
|
35
|
+
pluginZip?: string;
|
|
36
|
+
devPluginDir?: string;
|
|
37
|
+
mode?: "build" | "dev";
|
|
38
|
+
/** moment の置き場所(MCP は束ねた本体の隣の vendor/) */
|
|
39
|
+
vendorDir?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface SaveContext {
|
|
42
|
+
/** 作業フォルダーの実際のパス */
|
|
43
|
+
root: string;
|
|
44
|
+
/** 動く形(kintone/ の下を読む・変えてよいか。workspace.ts の modeOf) */
|
|
45
|
+
mode: WorkspaceMode;
|
|
46
|
+
policy: Policy;
|
|
47
|
+
source: EvalSource;
|
|
48
|
+
/** Worker の動かし方(時間上限、入口、出力の受け取り先) */
|
|
49
|
+
run?: RunOptions;
|
|
50
|
+
/** 評価の文脈の接続先(検証済み。APP_URL などの元) */
|
|
51
|
+
baseUrl?: string;
|
|
52
|
+
/** ユーザー情報のテストデータ(無ければ既定の架空の 10 人) */
|
|
53
|
+
usersSource?: UsersSource;
|
|
54
|
+
usersOrigin?: UsersOrigin;
|
|
55
|
+
lang?: Lang;
|
|
56
|
+
/** 試験用: 確定の直後(片付けの前)に呼ぶ。MCP は渡さない */
|
|
57
|
+
afterPlace?: () => void;
|
|
58
|
+
}
|
|
59
|
+
/** 入力(content / rows / common)の上限(バイト) */
|
|
60
|
+
export declare const MAX_SAVE_INPUT_BYTES: number;
|
|
61
|
+
/** updateFields の rows の行数の上限 */
|
|
62
|
+
export declare const MAX_UPDATE_ROWS = 50;
|
|
63
|
+
/** updateFields の common で置き換えられる共通の設定のキー(封筒と pluginInfos 以外の最上位のキー。設定ファイル仕様の順。Codex のレビュー MAJOR 4) */
|
|
64
|
+
export declare const COMMON_KEYS: readonly string[];
|
|
65
|
+
/** ファイルの digest(sha256。fml_summary が返し、fml_update_fields が照合する) */
|
|
66
|
+
export declare function digestOf(text: string | Buffer): string;
|
|
67
|
+
/** 接続の誤りの状態(print-craft MCP の 15.10 の表) */
|
|
68
|
+
export declare function connectionStatusOf(e: ConnectionError): Exclude<SaveStatus, "ok">;
|
|
69
|
+
/** 新しい設定を保存する(expectedAbsent: true が要る。同じ名前のファイルがあれば conflict) */
|
|
70
|
+
export declare function saveNewSettings(ctx: SaveContext, opt: {
|
|
71
|
+
path: string;
|
|
72
|
+
content: string;
|
|
73
|
+
fields?: string;
|
|
74
|
+
expectedAbsent: true;
|
|
75
|
+
}): Promise<SaveResult>;
|
|
76
|
+
/**
|
|
77
|
+
* 既存の設定の項目の行を差し替える(rows は fieldcode の行の JSON の配列の文字列。common は共通の設定の JSON の文字列)。
|
|
78
|
+
* expectedDigest は fml_summary(summary)が返した値。差し替えた後の設定を normalize し、エラーが無ければ確定する
|
|
79
|
+
*/
|
|
80
|
+
export declare function updateFields(ctx: SaveContext, opt: {
|
|
81
|
+
path: string;
|
|
82
|
+
expectedDigest: string;
|
|
83
|
+
rows: string;
|
|
84
|
+
common?: string;
|
|
85
|
+
fields?: string;
|
|
86
|
+
}): Promise<SaveResult>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type WorkspaceMode } from "../workspace.ts";
|
|
2
|
+
export interface TakeResult {
|
|
3
|
+
/** leftInInbox: 行き先には置いたが inbox の元を消せなかった(消してよい。次の take でも「同じもの」として消す) */
|
|
4
|
+
moved: Array<{
|
|
5
|
+
file: string;
|
|
6
|
+
to: string;
|
|
7
|
+
same: boolean;
|
|
8
|
+
leftInInbox?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
/** reason は決まった文(ファイルの中身・絶対パス・秘密の値を入れない。Codex の実装レビュー BLOCKER 1) */
|
|
11
|
+
skipped: Array<{
|
|
12
|
+
file: string;
|
|
13
|
+
reason: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** 置いたが一時ファイルを消せなかった、など(移したことは変わらない) */
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function takeInbox(cwdIn: string, mode: WorkspaceMode, profile?: string): TakeResult;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const LOCK_STALE_MS = 60000;
|
|
2
|
+
/** 確定先に同じ名前のファイルが既にある(確かめた後に作られた場合を含む) */
|
|
3
|
+
export declare class FileExistsError extends Error {
|
|
4
|
+
}
|
|
5
|
+
/** 同じファイルへの別の書き込みがロックを持っている */
|
|
6
|
+
export declare class LockBusyError extends Error {
|
|
7
|
+
}
|
|
8
|
+
/** EPERM / EBUSY なら短く待ってやり直す(tries 回まで)。それ以外の失敗はそのまま投げる */
|
|
9
|
+
export declare function withRetry<T>(fn: () => T, tries?: number): T;
|
|
10
|
+
/** 片付けを 1 つずつ試し、失敗の文を返す(一方の失敗で他方を飛ばさない。EPERM / EBUSY は短く待ってやり直す) */
|
|
11
|
+
export declare function cleanupAll(steps: Array<() => void>, tries?: number): string[];
|
|
12
|
+
/** 確定先と同じフォルダーの一時ファイルの名前 */
|
|
13
|
+
export declare function tempPathFor(target: string): string;
|
|
14
|
+
/** 一時ファイルを新しい名前で確定する(同じ名前があれば FileExistsError。上書きしない)。link は試験用(ハードリンクが使えない場合を作る) */
|
|
15
|
+
export declare function placeNew(tmp: string, target: string, link?: (from: string, to: string) => void): void;
|
|
16
|
+
export interface WriteNewResult {
|
|
17
|
+
/** 確定の後の片付けの失敗(確定はしている) */
|
|
18
|
+
cleanup: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 新しいファイルとして書く。recheck は一時ファイルを書く前と確定の直前に呼ぶ(書ける場所・許可を確かめ直す。投げれば確定しない)。
|
|
22
|
+
* 同じ名前があれば FileExistsError(確かめた後に作られた場合も)。失敗したら一時ファイルを消す
|
|
23
|
+
*/
|
|
24
|
+
export declare function writeNewFile(target: string, text: string, recheck?: () => void): WriteNewResult;
|
|
25
|
+
export interface Lock {
|
|
26
|
+
/** まだ自分のロックか(確定の直前に確かめる) */
|
|
27
|
+
owned(): boolean;
|
|
28
|
+
/** 自分のロックなら外す(他の保存が取り直したロックは消さない)。外したら true */
|
|
29
|
+
release(): boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function lockPathFor(target: string): string;
|
|
32
|
+
/** 試験用: 古いロックを付け替える直前・戻す直前に呼ぶ(その間に替わる場合を作る) */
|
|
33
|
+
export interface LockTestHooks {
|
|
34
|
+
beforeClaim?: () => void;
|
|
35
|
+
beforeRestore?: () => void;
|
|
36
|
+
}
|
|
37
|
+
/** 確定先のロックを取る。取れなければ LockBusyError */
|
|
38
|
+
export declare function acquireLock(target: string, staleMs?: number, hooks?: LockTestHooks): Lock;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type Stats } from "node:fs";
|
|
2
|
+
import type { KintoneAuth } from "./env.ts";
|
|
3
|
+
export declare const CONNECTION_MAX_BYTES: number;
|
|
4
|
+
/** 接続のファイルを読むときの fs の呼び出し(試験だけが差し替える。読み込みの途中の書き換えを再現するため。中核の入口 core.ts からは出さない) */
|
|
5
|
+
interface FsOps {
|
|
6
|
+
openSync: (p: string, flags: string) => number;
|
|
7
|
+
fstatSync: (fd: number) => Stats;
|
|
8
|
+
readSync: (fd: number, buf: Buffer, offset: number, length: number, position: number) => number;
|
|
9
|
+
closeSync: (fd: number) => void;
|
|
10
|
+
statSync: (p: string) => Stats;
|
|
11
|
+
}
|
|
12
|
+
/** 試験用: fs の呼び出しを差し替える(undefined で元に戻す) */
|
|
13
|
+
export declare function setFsOpsForTest(ops?: Partial<FsOps>): void;
|
|
14
|
+
/** profile の名前(kintone/<profile>/ のフォルダーの名前になる) */
|
|
15
|
+
export declare const PROFILE_NAME_RE: RegExp;
|
|
16
|
+
/** kSQL と同じ: 引数も defaultProfile も無ければ dev(15.1 の 8) */
|
|
17
|
+
export declare const FALLBACK_PROFILE = "dev";
|
|
18
|
+
/** 誤りの種類(15.10。status は呼ぶ側が決める: inside-workspace は denied、unknown-profile と guest-mismatch は invalid、印と connection-changed は conflict、ほかは failed) */
|
|
19
|
+
export type ConnectionErrorCode = "not-configured" | "unreadable" | "inside-workspace" | "legacy-config-present" | "unknown-profile" | "no-default-profile" | "profile-invalid" | "no-token" | "env-missing" | "no-userpass" | "no-user-api-auth" | "guest-mismatch" | "app-marker-missing" | "app-marker-invalid" | "app-identity-conflict" | "connection-changed";
|
|
20
|
+
export declare class ConnectionError extends Error {
|
|
21
|
+
readonly code: ConnectionErrorCode;
|
|
22
|
+
constructor(message: string, code: ConnectionErrorCode);
|
|
23
|
+
}
|
|
24
|
+
export type Env = Readonly<Record<string, string | undefined>>;
|
|
25
|
+
/** profile の秘密でない識別(アプリのフォルダーの印と、確定の前の比較に使う) */
|
|
26
|
+
export interface ProfileIdentity {
|
|
27
|
+
profile: string;
|
|
28
|
+
baseUrl: string;
|
|
29
|
+
host: string;
|
|
30
|
+
/** ゲストスペースの番号(通常のスペースは null) */
|
|
31
|
+
guestSpaceId: number | null;
|
|
32
|
+
}
|
|
33
|
+
export interface ProfileDef extends ProfileIdentity {
|
|
34
|
+
/** auto を解決した後の認証の種類 */
|
|
35
|
+
auth: "token" | "userpass";
|
|
36
|
+
/** tokenMap のアプリの番号(値は持たない) */
|
|
37
|
+
tokenApps: number[];
|
|
38
|
+
/** アプリごとに、トークンが使えるか(env: の変数があるか。変数の名前は持たない) */
|
|
39
|
+
tokenReady: Record<number, boolean>;
|
|
40
|
+
/** ログイン名とパスワードがそろっているか(userpass のとき) */
|
|
41
|
+
userpassReady: boolean;
|
|
42
|
+
/** User API の cybozu.com 共通の API トークンがあるか(userApiToken。env: なら変数があるか。値は持たない) */
|
|
43
|
+
userApiTokenReady: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ConnectionSet {
|
|
46
|
+
/** 接続のファイルの名前(パスは持たない。応答に出してよいのはこれだけ) */
|
|
47
|
+
fileName: string;
|
|
48
|
+
/** 中身の sha256 */
|
|
49
|
+
digest: string;
|
|
50
|
+
/** ファイルに書いた defaultProfile(無ければ undefined) */
|
|
51
|
+
defaultProfile?: string;
|
|
52
|
+
/** 使える profile */
|
|
53
|
+
profiles: ReadonlyMap<string, ProfileDef>;
|
|
54
|
+
/** 使えない profile と理由(決まった文。値を含まない) */
|
|
55
|
+
invalid: ReadonlyArray<{
|
|
56
|
+
name: string;
|
|
57
|
+
reason: string;
|
|
58
|
+
}>;
|
|
59
|
+
/** 警告(ほかの利用者が読める、など。パスを含まない) */
|
|
60
|
+
warnings: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 接続のスナップショット(15.6): 呼び出しの初めに選んだ profile の秘密でない値。kintone の API・保存先・アプリのフォルダーの印・preview の接続先に同じものを使い、
|
|
64
|
+
* 確定の直前に読み直した profile の意味の digest(semanticDigest)と比べる。ファイル全体の digest は使わない(ほかの profile だけの書き換えでは止めない)
|
|
65
|
+
*/
|
|
66
|
+
export interface ConnectionSnapshot extends ProfileIdentity {
|
|
67
|
+
auth: "token" | "userpass";
|
|
68
|
+
/** 読んだ接続のファイルの名前(文に出してよいのはこれだけ) */
|
|
69
|
+
fileName: string;
|
|
70
|
+
}
|
|
71
|
+
export interface LoadConnectionsOptions {
|
|
72
|
+
/** そのプロセスが知っている作業フォルダー(この中の接続のファイルは使わない) */
|
|
73
|
+
workspaceRoots: readonly string[];
|
|
74
|
+
/** env: と passwordEnv を引く環境変数(中核は process.env を読まない) */
|
|
75
|
+
env: Env;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 接続のファイルを読む(15.2、15.3)。file は絶対パス(設定の値の ~ の展開と引用符を外すのは呼ぶ側)。
|
|
79
|
+
* 読めない・作業フォルダーの中は ConnectionError。profile ごとの誤りは invalid に入れる(ほかの profile は使える)
|
|
80
|
+
*/
|
|
81
|
+
export declare function loadConnections(file: string | undefined, opt: LoadConnectionsOptions): ConnectionSet;
|
|
82
|
+
/** profile を選ぶ(15.2: 引数 → defaultProfile → "dev") */
|
|
83
|
+
export declare function pickProfile(set: ConnectionSet, name?: string): ProfileDef;
|
|
84
|
+
/** 選んだ profile のスナップショット(15.6) */
|
|
85
|
+
export declare function snapshotOf(set: ConnectionSet, def: ProfileDef): ConnectionSnapshot;
|
|
86
|
+
/**
|
|
87
|
+
* 選んだ profile の意味の digest(15.6): profile、接続先、ゲストスペース、認証の種類、対象のアプリと、資格情報の指紋(解決したログイン名とパスワード、
|
|
88
|
+
* または対象のアプリのトークンの HMAC。鍵はプロセスごとの乱数)。直接書いた値・ログイン名・env: の参照先の値の入れ替えも違う digest になる(r3 MAJOR 1)。
|
|
89
|
+
* この digest も指紋も外に出さない(このプロセスの中で比べるだけ)
|
|
90
|
+
*/
|
|
91
|
+
export declare function semanticDigest(set: ConnectionSet, def: ProfileDef, appId?: number): string;
|
|
92
|
+
/** 確定の直前に、読み直した接続で同じ profile の意味の digest が同じか(違えば connection-changed) */
|
|
93
|
+
export declare function assertSameConnection(before: {
|
|
94
|
+
set: ConnectionSet;
|
|
95
|
+
def: ProfileDef;
|
|
96
|
+
}, reload: () => ConnectionSet, appId?: number): void;
|
|
97
|
+
/** アプリ N の認証(15.2)。対象のアプリのトークンだけを解決する */
|
|
98
|
+
export declare function authFor(set: ConnectionSet, profile: ProfileDef, appId: number): KintoneAuth;
|
|
99
|
+
/**
|
|
100
|
+
* User API(users --pull)の認証(計算式の tools の拡張): profile の userApiToken(cybozu.com 共通管理の API トークン。Bearer)があればそれ、
|
|
101
|
+
* 無ければログイン名とパスワード(2 要素認証のないアカウント)。アプリの API トークン(tokenMap)では User API を呼べないので使わない
|
|
102
|
+
*/
|
|
103
|
+
export declare function userApiAuthFor(set: ConnectionSet, profile: ProfileDef): KintoneAuth;
|
|
104
|
+
export declare function identityOf(def: ProfileDef): ProfileIdentity;
|
|
105
|
+
export declare function sameIdentity(a: ProfileIdentity, b: ProfileIdentity): boolean;
|
|
106
|
+
export {};
|
package/dist/types/core.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 中核の入口(@rex0220/formula-authoring-tools/core
|
|
3
|
-
* 工程 0(2026-10-17): 読み込み(engine)、ダミー層(context)、ユーザー情報のテストデータ、zip
|
|
2
|
+
* 中核の入口(@rex0220/formula-authoring-tools/core。formula MCP が使う)。cli.ts と dev-paths.ts は含めない(環境変数と process.cwd を読むのは CLI だけ)。
|
|
3
|
+
* 工程 0(2026-10-17): 読み込み(engine)、ダミー層(context)、ユーザー情報のテストデータ、zip の読み込み、安全なパス、接続。
|
|
4
|
+
* tools 0.2.0(計画 24.4。CORE_API_VERSION 2): 作業フォルダーとアプリのフォルダー(workspace)、接続のファイル(connections)、kintone/ の下の許可(permission)、
|
|
5
|
+
* ファイルの確定とロック(commit-file)、take、保存の約束(save: saveNewSettings / updateFields)、users の参照するコードの取得、JSON の誤りの文、行のキー
|
|
4
6
|
*/
|
|
5
|
-
export declare const CORE_API_VERSION =
|
|
7
|
+
export declare const CORE_API_VERSION = 2;
|
|
6
8
|
export { createContext, type WorkContext } from "./context.ts";
|
|
7
|
-
export { PathError, WRITE_ROOTS, isInside, realResolve, resolveRead, resolveWrite } from "./safe-path.ts";
|
|
8
|
-
export { FORMULA_PLUGIN_ID, MIN_PLUGIN_VERSION, SUPPORTED_API_VERSIONS, REQUIRED_API, isSupportedPluginVersion, schemaRevisionOf, toolsMeta, type ToolsMeta } from "./meta.ts";
|
|
9
|
-
export { DEFAULT_CONTEXT_BASE_URL, SENTINEL_USER, loadEngine, resolvePluginSources, type CalcEvent, type Engine, type EngineContext, type EngineSource, type FormulaAuthoringApi, type FormulaInstance, type LoadEngineOptions, type LoginUser, type SinkCall } from "./engine.ts";
|
|
9
|
+
export { PathError, WRITE_ROOTS, isInside, realResolve, resolveRead, resolveWrite, resolveWriteDir, safeFileName } from "./safe-path.ts";
|
|
10
|
+
export { FORMULA_PLUGIN_ID, FORMULA_CONFIG_PLUGIN_ID, MIN_PLUGIN_VERSION, SUPPORTED_API_VERSIONS, REQUIRED_API, isSupportedPluginVersion, schemaRevisionOf, toolsMeta, type ToolsMeta } from "./meta.ts";
|
|
11
|
+
export { DEFAULT_CONTEXT_BASE_URL, SENTINEL_USER, loadEngine, momentFileOf, resolvePluginSources, type CalcEvent, type Engine, type EngineContext, type EngineSource, type FormulaAuthoringApi, type FormulaInstance, type LoadEngineOptions, type LoginUser, type SinkCall } from "./engine.ts";
|
|
10
12
|
export { PluginZipError, pluginIdOf, readPluginZip, type PluginSources, type PluginZipErrorCode, type PluginZipErrorInfo } from "./plugin-zip.ts";
|
|
11
13
|
export { DEFAULT_USERS, UsersDataError, buildUsersInfo, defaultUsersInfo, summarizeUsers, validateUsersSource, type UsersInfoTable, type UsersOrigin, type UsersSource } from "./users/index.ts";
|
|
12
|
-
export { AuthError, baseUrlFromEnv, describeAuth, kintoneConfigPath, loadAuth, pluginZipPath, unquote, type KintoneAuth, type LoadAuthOptions } from "./env.ts";
|
|
14
|
+
export { AuthError, baseUrlFromEnv, describeAuth, kintoneConfigPath, loadAuth, loadUserApiAuth, pluginZipPath, unquote, type KintoneAuth, type LoadAuthOptions } from "./env.ts";
|
|
13
15
|
export { KintoneUrlError, isKintoneBaseUrl, normalizeKintoneBaseUrl } from "./kintone-url.ts";
|
|
14
16
|
export { InputError, MAX_INPUT_BYTES, PLUGIN_NAME, formatDate, jsonDiff, readFieldsFile, readJsonLimited, readTextLimited, relativeSettingsPath } from "./input.ts";
|
|
17
|
+
export { jsonErrorText, jsonErrorWhere } from "./json-error.ts";
|
|
15
18
|
export { ALLOWED_APIS, ALLOWED_USER_APIS, NotAllowedError, RECEIVE_LIMITS, RestError, createRestClient, type AllowedApi, type AllowedUserApi, type FetchLike, type RestClient } from "./kintone-rest.ts";
|
|
16
19
|
export { scanFormula, scanFormulas, type ScanResult } from "./scan.ts";
|
|
17
20
|
export { contextTargetsOf, fetchFields, listFields, referenceTablesOf, summarizeFields, type FieldProperty, type FieldsFile, type FieldsOptions, type LayoutRow } from "./commands/fields.ts";
|
|
@@ -20,13 +23,18 @@ export { LIST_LIMIT, QUERY_MAX, QueryError, SHAPE_TEXT_MAX, listQueryOf, listRec
|
|
|
20
23
|
export { defaultPullName, pullSettings, type PullOptions, type PullResult } from "./commands/pull.ts";
|
|
21
24
|
export { bodyOf, rowsOf, summarizeSettings, type Envelope, type SourceRow } from "./commands/summary.ts";
|
|
22
25
|
export { diffSettings, type DiffResult, type FieldChange } from "./commands/diff.ts";
|
|
23
|
-
export { DEFAULT_MAX_CALLS, UsersPullError, pullUsers, usersFileNameOf, type PullUsersOptions } from "./commands/users.ts";
|
|
24
|
-
export { normalizeSettings, findCycles, type NormalizeInput, type NormalizeResult } from "./commands/normalize.ts";
|
|
26
|
+
export { DEFAULT_MAX_CALLS, USER_INFO_FUNCTIONS, UsersPullError, pullReferencedUsers, pullUsers, referencedCodesOf, scanUserInfoCalls, usersFileNameOf, type PullUsersOptions, type ReferencedCodes } from "./commands/users.ts";
|
|
27
|
+
export { normalizeSettings, findCycles, stronglyConnected, type ContextNeeds, type NormalizeInput, type NormalizeResult } from "./commands/normalize.ts";
|
|
25
28
|
export { DEFAULT_EVENT, EVENT_RE, RECORDS_MAX, calcSettings, validateEvent, type CalcInput, type CalcLine, type CalcRecordResult, type CalcResult } from "./commands/calc.ts";
|
|
29
|
+
export { takeInbox, type TakeResult } from "./commands/take.ts";
|
|
30
|
+
export { COMMON_KEYS, MAX_SAVE_INPUT_BYTES, MAX_UPDATE_ROWS, connectionStatusOf, digestOf, saveNewSettings, updateFields, type EvalSource, type SaveContext, type SaveResult, type SaveStatus } from "./commands/save.ts";
|
|
26
31
|
export { DEFAULT_POLICY, POLICY_FILE, PolicyError, loadPolicy, parsePolicy, type Policy } from "./normalize/policy.ts";
|
|
27
32
|
export { Findings, type Finding, type Level } from "./normalize/findings.ts";
|
|
28
|
-
export { materialsOf, viewsOf, type FormulaSaved, type FormulaSource, type Lang } from "./normalize/model.ts";
|
|
33
|
+
export { ENVELOPE_KEYS, OUTER_KEYS, ROW_SCREEN_KEYS, ROW_SOURCE_KEYS, materialsOf, viewsOf, type FormulaSaved, type FormulaSource, type Lang } from "./normalize/model.ts";
|
|
29
34
|
export { DEFAULT_TIMEOUT_SEC, EvalError, EvalTimeoutError, MAX_TIMEOUT_SEC, runEval, type RunOptions } from "./worker/run.ts";
|
|
30
|
-
export { runEvalJob } from "./worker/eval-run.ts";
|
|
31
|
-
export type { EvalJob, EvalMessage, EvalOutcome } from "./worker/eval-job.ts";
|
|
32
|
-
export {
|
|
35
|
+
export { builtinErrorName, classifyEvalError, runEvalJob } from "./worker/eval-run.ts";
|
|
36
|
+
export type { EvalErrorKind, EvalJob, EvalMessage, EvalOutcome } from "./worker/eval-job.ts";
|
|
37
|
+
export { APP_MARKER, EDIT_RE, INBOX, KINTONE_ROOT, LEGACY_WORKSPACE_FILE, SNAPSHOT_PREFIX, SNAPSHOT_RE, WorkspaceError, appDirFor, appFolderOfFile, appFoldersOf, assertAppMark, assertInsideWorkspace, assertUsableInKintone, editNameOf, ensureAppFolder, findAppDir, folderNameOf, hasLegacyConfig, legacyBlockedError, listAppFolder, markOf, modeOf, profileDirOf, readAppMark, requireProfiles, snapshotNameOf, unusedProfileDirs, type AppFolderList, type AppMark, type AppMarkState, type ModeOptions, type ProfilesContext, type WorkspaceMode } from "./workspace.ts";
|
|
38
|
+
export { CONNECTION_MAX_BYTES, ConnectionError, FALLBACK_PROFILE, PROFILE_NAME_RE, assertSameConnection, authFor, identityOf, loadConnections, pickProfile, sameIdentity, semanticDigest, snapshotOf, userApiAuthFor, type ConnectionErrorCode, type ConnectionSet, type ConnectionSnapshot, type Env, type LoadConnectionsOptions, type ProfileDef, type ProfileIdentity } from "./connections.ts";
|
|
39
|
+
export { PermissionError, assertChangeAllowed, classOfAppPath, type ChangeOp, type TargetClass } from "./permission.ts";
|
|
40
|
+
export { FileExistsError, LOCK_STALE_MS, LockBusyError, acquireLock, cleanupAll, lockPathFor, placeNew, tempPathFor, withRetry, writeNewFile, type Lock, type WriteNewResult } from "./commit-file.ts";
|
package/dist/types/engine.d.ts
CHANGED
|
@@ -99,7 +99,11 @@ export interface LoadEngineOptions {
|
|
|
99
99
|
/** 開発中(mode dev)の読み込み元(隣の formula の prod/)。CLI は FORMULA_ALLOW_DEV_PLUGIN=1 のときだけ dev-paths.ts の formulaProdDir で決めて渡す */
|
|
100
100
|
devPluginDir?: string;
|
|
101
101
|
mode?: "build" | "dev";
|
|
102
|
+
/** moment(vendor/)の置き場所。省略すれば tools の vendor/(paths.ts)。MCP は束ねた本体の隣の vendor/ を渡す(tools 0.2.0) */
|
|
103
|
+
vendorDir?: string;
|
|
102
104
|
}
|
|
105
|
+
/** moment のファイル(vendorDir があればその中。無ければ tools の vendor/) */
|
|
106
|
+
export declare function momentFileOf(opt: LoadEngineOptions): string;
|
|
103
107
|
export declare const DEFAULT_CONTEXT_BASE_URL = "https://example.cybozu.com";
|
|
104
108
|
/** 指定が無いときにコンストラクターへ返す番兵(式が使えば走査で止める。calc の表には「ログインユーザー: 指定なし」) */
|
|
105
109
|
export declare const SENTINEL_USER: LoginUser;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PermissionError } from "./permission-error.ts";
|
|
2
|
+
import { type WorkspaceMode } from "./workspace.ts";
|
|
3
|
+
export { PermissionError };
|
|
4
|
+
export type ChangeOp = "settings" | "snapshot" | "fields" | "record";
|
|
5
|
+
/** アプリのフォルダーの中の場所(print-craft の docs/permission-table.md の P4〜P9 から out/ を除いたもの) */
|
|
6
|
+
export type TargetClass = "snapshot" | "edit" | "newsettings" | "fields" | "record" | "other";
|
|
7
|
+
/** アプリのフォルダーからの相対パスで場所を分ける。. で始まる名前(印など)はどの操作でも書けない other */
|
|
8
|
+
export declare function classOfAppPath(relInFolder: string): TargetClass;
|
|
9
|
+
/** kintone/ の下をこの操作で変えてよいか。だめなら PermissionError(denied)か ConnectionError(印・接続の変化は conflict。移行で止まっているのは failed) */
|
|
10
|
+
export declare function assertChangeAllowed(root: string, file: string, op: ChangeOp, mode: WorkspaceMode): void;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Worker に渡す仕事と返す結果(構造化クローンで渡せる形だけ。関数やクラスは渡さない)。
|
|
3
3
|
* normalize / calc の評価(zip のコードの実行)は Worker の中で行い、主スレッドは時間上限で terminate する(計画 7 章・11 章、Codex レビュー BLOCKER 1)。
|
|
4
|
+
* tools 0.2.0(MCP。計画 24 章): 結果に findings と calc のレコードごとの行を足した(MCP が構造のまま返す。CLI は summary / text を使う)。vendorDir(moment の置き場所)
|
|
4
5
|
*/
|
|
5
6
|
import type { FieldsFile } from "../commands/fields.ts";
|
|
6
7
|
import type { KintoneRecord } from "../commands/record.ts";
|
|
8
|
+
import type { CalcRecordResult } from "../commands/calc.ts";
|
|
9
|
+
import type { Finding } from "../normalize/findings.ts";
|
|
7
10
|
import type { Policy } from "../normalize/policy.ts";
|
|
8
11
|
import type { UsersOrigin, UsersSource } from "../users/index.ts";
|
|
9
12
|
import type { CalcEvent } from "../engine.ts";
|
|
@@ -13,6 +16,8 @@ export interface EvalJob {
|
|
|
13
16
|
pluginZip?: string;
|
|
14
17
|
devPluginDir?: string;
|
|
15
18
|
mode?: "build" | "dev";
|
|
19
|
+
/** moment(vendor/)の置き場所(省略すれば tools の vendor/。MCP は束ねた本体の隣) */
|
|
20
|
+
vendorDir?: string;
|
|
16
21
|
/** 接続先(検証済み。APP_URL などの元。無ければ既定) */
|
|
17
22
|
baseUrl?: string;
|
|
18
23
|
settingsText: string;
|
|
@@ -42,23 +47,42 @@ export interface EvalOutcome {
|
|
|
42
47
|
summary: string;
|
|
43
48
|
hasErrors: boolean;
|
|
44
49
|
warnings: number;
|
|
50
|
+
/** 検査の結果(エラー / 警告 / 情報。MCP が返す) */
|
|
51
|
+
findings: Finding[];
|
|
45
52
|
output?: Record<string, unknown>;
|
|
46
53
|
checkDiffs?: string[];
|
|
54
|
+
/** 封筒の appId と、保存値の大きさの見積もり */
|
|
55
|
+
appId?: number;
|
|
56
|
+
size?: {
|
|
57
|
+
bytes: number;
|
|
58
|
+
keys: number;
|
|
59
|
+
};
|
|
47
60
|
};
|
|
48
61
|
calc?: {
|
|
49
62
|
text: string;
|
|
50
63
|
/** エラーか sink のあるレコードがある */
|
|
51
64
|
failed: boolean;
|
|
65
|
+
/** レコードごとの結果(項目ごとの前後の値。MCP が返す) */
|
|
66
|
+
records: CalcRecordResult[];
|
|
67
|
+
contextLine: string;
|
|
68
|
+
notice: string;
|
|
69
|
+
summary: string;
|
|
52
70
|
};
|
|
53
71
|
/** エンジンの読み込みの注意 */
|
|
54
72
|
engineWarnings: string[];
|
|
55
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Worker の中の誤りの種類(信頼できる境界 = 中核の eval-run.ts が instanceof で決める。zip のコードが name を偽装しても変わらない。Codex の r2 レビュー R1):
|
|
76
|
+
* input(中核の InputError)、zip(PluginZipError。code 付き)、users(UsersDataError)、policy(PolicyError)、other(zip のコードの例外など。文は信用しない)
|
|
77
|
+
*/
|
|
78
|
+
export type EvalErrorKind = "input" | "zip" | "users" | "policy" | "other";
|
|
56
79
|
export type EvalMessage = {
|
|
57
80
|
ok: true;
|
|
58
81
|
outcome: EvalOutcome;
|
|
59
82
|
} | {
|
|
60
83
|
ok: false;
|
|
61
84
|
error: {
|
|
85
|
+
kind: EvalErrorKind;
|
|
62
86
|
name: string;
|
|
63
87
|
message: string;
|
|
64
88
|
code?: string;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import type { EvalJob, EvalOutcome } from "./eval-job.ts";
|
|
1
|
+
import type { EvalJob, EvalMessage, EvalOutcome } from "./eval-job.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Worker の中の誤りを種類に分ける(instanceof で。中核のクラスは zip のコードから届かないので、name の偽装では input / zip にならない)。
|
|
4
|
+
* name も instanceof で決めた固定の名前(中核のクラスの名前か、JavaScript の組み込みの Error の名前。例外の name / constructor.name は使わない =
|
|
5
|
+
* zip のコードが name に値やパスを入れても出ない。Codex の r3 レビュー N1)。文は other のときは信用しない(呼ぶ側が決まった文にする)
|
|
6
|
+
*/
|
|
7
|
+
export declare function classifyEvalError(e: unknown): Extract<EvalMessage, {
|
|
8
|
+
ok: false;
|
|
9
|
+
}>["error"];
|
|
10
|
+
/** JavaScript の組み込みの Error の種類(instanceof。同じ realm で動く zip のコードの例外も、この判定は偽装できない)。それ以外は Error */
|
|
11
|
+
export declare function builtinErrorName(e: unknown): string;
|
|
2
12
|
export declare function runEvalJob(job: EvalJob): Promise<EvalOutcome>;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import type { EvalJob, EvalOutcome } from "./eval-job.ts";
|
|
1
|
+
import type { EvalErrorKind, EvalJob, EvalOutcome } from "./eval-job.ts";
|
|
2
2
|
export declare const DEFAULT_TIMEOUT_SEC = 60;
|
|
3
3
|
export declare const MAX_TIMEOUT_SEC = 600;
|
|
4
4
|
export declare class EvalTimeoutError extends Error {
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Worker の中の誤り(kind / name / code を持って主スレッドに戻す)。kind は中核が instanceof で決めた信頼できる種類(input / zip / users / policy / other)。
|
|
8
|
+
* innerName は参考の名前(other のときは zip のコードが付けた名前かもしれない)。other のときの文は値やパスを含みうる(MCP は返さない)
|
|
9
|
+
*/
|
|
7
10
|
export declare class EvalError extends Error {
|
|
8
11
|
readonly innerName: string;
|
|
9
12
|
readonly code?: string;
|
|
10
|
-
|
|
13
|
+
readonly kind: EvalErrorKind;
|
|
14
|
+
constructor(message: string, innerName: string, code?: string, kind?: EvalErrorKind);
|
|
11
15
|
}
|
|
12
16
|
export interface RunOptions {
|
|
13
17
|
timeoutSec?: number;
|
|
14
18
|
/** 主スレッドで動かす(テスト) */
|
|
15
19
|
inline?: boolean;
|
|
20
|
+
/** Worker の入口(絶対パス)。省略すれば自分の隣の eval-worker.mjs / eval-worker.ts */
|
|
21
|
+
workerFile?: string;
|
|
22
|
+
/** Worker の標準出力・標準エラーの受け取り先(渡すと親の標準出力・標準エラーに流さない) */
|
|
23
|
+
captureOutput?: (chunk: string, stream: "stdout" | "stderr") => void;
|
|
16
24
|
}
|
|
17
25
|
export declare function runEval(job: EvalJob, opt?: RunOptions): Promise<EvalOutcome>;
|