memorix 1.9.2 → 1.9.4
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/CHANGELOG.md +27 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/cli/index.js +358 -146
- package/dist/index.js +281 -125
- package/dist/maintenance-runner.js +219 -97
- package/dist/media-audio-runner.js +219 -97
- package/dist/media-video-runner.js +219 -97
- package/dist/memcode-runtime/CHANGELOG.md +27 -0
- package/dist/sdk.js +280 -124
- package/dist/vector-backfill-runner.js +219 -97
- package/docs/AGENT_OPERATOR_PLAYBOOK.md +15 -0
- package/docs/ARCHITECTURE.md +23 -0
- package/docs/DEVELOPMENT.md +1 -1
- package/docs/PERFORMANCE.md +50 -0
- package/docs/README.md +1 -1
- package/package.json +1 -1
- package/plugins/antigravity/memorix/plugin.json +1 -1
- package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
- package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
- package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/copilot/memorix/plugin.json +1 -1
- package/plugins/gemini/memorix/gemini-extension.json +1 -1
- package/plugins/hermes/memorix/plugin.yaml +1 -1
- package/plugins/omp/memorix/package.json +1 -1
- package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
- package/plugins/pi/memorix/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/doctor.ts +78 -17
- package/src/cli/commands/media.ts +2 -0
- package/src/media/minimax.ts +26 -2
- package/src/media/video-jobs.ts +9 -1
- package/src/server.ts +3 -1
- package/src/store/mini-skill-store.ts +31 -22
- package/src/store/obs-store.ts +46 -30
- package/src/store/session-store.ts +35 -21
- package/src/store/sqlite-db.ts +16 -7
- package/src/store/sqlite-reliability.ts +87 -0
- package/src/store/sqlite-store.ts +4 -1
|
@@ -388,70 +388,79 @@ function getDatabase(dataDir) {
|
|
|
388
388
|
loadBetterSqlite3();
|
|
389
389
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
390
390
|
const dbPath = path3.join(dataDir, "memorix.db");
|
|
391
|
-
|
|
392
|
-
db2.pragma("journal_mode = WAL");
|
|
393
|
-
db2.pragma("busy_timeout = 5000");
|
|
394
|
-
db2.pragma("foreign_keys = ON");
|
|
395
|
-
db2.exec(CREATE_OBSERVATIONS_TABLE);
|
|
396
|
-
db2.exec(CREATE_MINI_SKILLS_TABLE);
|
|
397
|
-
db2.exec(CREATE_SESSIONS_TABLE);
|
|
398
|
-
db2.exec(CREATE_META_TABLE);
|
|
399
|
-
db2.exec(CREATE_TEAM_AGENTS_TABLE);
|
|
400
|
-
db2.exec(CREATE_TEAM_TASKS_TABLE);
|
|
401
|
-
db2.exec(CREATE_TEAM_TASK_DEPS_TABLE);
|
|
402
|
-
db2.exec(CREATE_TEAM_MESSAGES_TABLE);
|
|
403
|
-
db2.exec(CREATE_TEAM_LOCKS_TABLE);
|
|
404
|
-
db2.exec(CREATE_TEAM_ROLES_TABLE);
|
|
405
|
-
db2.exec(CREATE_GRAPH_ENTITIES_TABLE);
|
|
406
|
-
db2.exec(CREATE_GRAPH_RELATIONS_TABLE);
|
|
407
|
-
db2.exec(CREATE_CHAT_TRANSCRIPT_TABLE);
|
|
408
|
-
db2.exec(CREATE_CODE_FILES_TABLE);
|
|
409
|
-
db2.exec(CREATE_CODE_SYMBOLS_TABLE);
|
|
410
|
-
db2.exec(CREATE_CODE_EDGES_TABLE);
|
|
411
|
-
db2.exec(CREATE_OBSERVATION_CODE_REFS_TABLE);
|
|
412
|
-
db2.exec(CREATE_MAINTENANCE_JOBS_TABLE);
|
|
413
|
-
db2.exec(CREATE_MAINTENANCE_TARGETS_TABLE);
|
|
414
|
-
db2.exec(CREATE_COMPACTION_CHECKPOINTS_TABLE);
|
|
391
|
+
let db2;
|
|
415
392
|
try {
|
|
416
|
-
db2
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
db2.exec(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
db2.exec(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
db2.exec(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
db2.exec(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
db2.exec(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
393
|
+
db2 = createDatabase(dbPath);
|
|
394
|
+
db2.pragma("busy_timeout = 5000");
|
|
395
|
+
db2.pragma("journal_mode = WAL");
|
|
396
|
+
db2.pragma("foreign_keys = ON");
|
|
397
|
+
db2.exec(CREATE_OBSERVATIONS_TABLE);
|
|
398
|
+
db2.exec(CREATE_MINI_SKILLS_TABLE);
|
|
399
|
+
db2.exec(CREATE_SESSIONS_TABLE);
|
|
400
|
+
db2.exec(CREATE_META_TABLE);
|
|
401
|
+
db2.exec(CREATE_TEAM_AGENTS_TABLE);
|
|
402
|
+
db2.exec(CREATE_TEAM_TASKS_TABLE);
|
|
403
|
+
db2.exec(CREATE_TEAM_TASK_DEPS_TABLE);
|
|
404
|
+
db2.exec(CREATE_TEAM_MESSAGES_TABLE);
|
|
405
|
+
db2.exec(CREATE_TEAM_LOCKS_TABLE);
|
|
406
|
+
db2.exec(CREATE_TEAM_ROLES_TABLE);
|
|
407
|
+
db2.exec(CREATE_GRAPH_ENTITIES_TABLE);
|
|
408
|
+
db2.exec(CREATE_GRAPH_RELATIONS_TABLE);
|
|
409
|
+
db2.exec(CREATE_CHAT_TRANSCRIPT_TABLE);
|
|
410
|
+
db2.exec(CREATE_CODE_FILES_TABLE);
|
|
411
|
+
db2.exec(CREATE_CODE_SYMBOLS_TABLE);
|
|
412
|
+
db2.exec(CREATE_CODE_EDGES_TABLE);
|
|
413
|
+
db2.exec(CREATE_OBSERVATION_CODE_REFS_TABLE);
|
|
414
|
+
db2.exec(CREATE_MAINTENANCE_JOBS_TABLE);
|
|
415
|
+
db2.exec(CREATE_MAINTENANCE_TARGETS_TABLE);
|
|
416
|
+
db2.exec(CREATE_COMPACTION_CHECKPOINTS_TABLE);
|
|
417
|
+
try {
|
|
418
|
+
db2.exec(`ALTER TABLE mini_skills ADD COLUMN sourceSnapshot TEXT NOT NULL DEFAULT ''`);
|
|
419
|
+
} catch {
|
|
420
|
+
}
|
|
421
|
+
try {
|
|
422
|
+
db2.exec(`ALTER TABLE mini_skills ADD COLUMN updatedAt TEXT`);
|
|
423
|
+
} catch {
|
|
424
|
+
}
|
|
425
|
+
try {
|
|
426
|
+
db2.exec(`ALTER TABLE observations ADD COLUMN createdByAgentId TEXT`);
|
|
427
|
+
} catch {
|
|
428
|
+
}
|
|
429
|
+
try {
|
|
430
|
+
db2.exec(`ALTER TABLE observations ADD COLUMN writeGeneration INTEGER DEFAULT 0`);
|
|
431
|
+
} catch {
|
|
432
|
+
}
|
|
433
|
+
try {
|
|
434
|
+
db2.exec(`ALTER TABLE team_tasks ADD COLUMN required_role TEXT`);
|
|
435
|
+
} catch {
|
|
436
|
+
}
|
|
437
|
+
try {
|
|
438
|
+
db2.exec(`ALTER TABLE team_tasks ADD COLUMN preferred_role TEXT`);
|
|
439
|
+
} catch {
|
|
440
|
+
}
|
|
441
|
+
try {
|
|
442
|
+
db2.exec(`ALTER TABLE team_messages ADD COLUMN to_role TEXT`);
|
|
443
|
+
} catch {
|
|
444
|
+
}
|
|
445
|
+
try {
|
|
446
|
+
db2.exec(`ALTER TABLE team_messages ADD COLUMN handoff_status TEXT`);
|
|
447
|
+
} catch {
|
|
448
|
+
}
|
|
449
|
+
applySchemaMigrations(db2);
|
|
450
|
+
db2.exec(CREATE_INDEXES);
|
|
451
|
+
initializeObservationLexicalIndex(db2);
|
|
452
|
+
db2.prepare(`INSERT OR IGNORE INTO meta (key, value) VALUES ('storage_generation', '0')`).run();
|
|
453
|
+
db2.prepare(`INSERT OR IGNORE INTO meta (key, value) VALUES ('next_id', '1')`).run();
|
|
454
|
+
db2.prepare(`INSERT OR IGNORE INTO meta (key, value) VALUES ('mini_skills_generation', '0')`).run();
|
|
455
|
+
_dbCache.set(normalized, db2);
|
|
456
|
+
return db2;
|
|
457
|
+
} catch (error) {
|
|
458
|
+
try {
|
|
459
|
+
db2?.close();
|
|
460
|
+
} catch {
|
|
461
|
+
}
|
|
462
|
+
throw error;
|
|
446
463
|
}
|
|
447
|
-
applySchemaMigrations(db2);
|
|
448
|
-
db2.exec(CREATE_INDEXES);
|
|
449
|
-
initializeObservationLexicalIndex(db2);
|
|
450
|
-
db2.prepare(`INSERT OR IGNORE INTO meta (key, value) VALUES ('storage_generation', '0')`).run();
|
|
451
|
-
db2.prepare(`INSERT OR IGNORE INTO meta (key, value) VALUES ('next_id', '1')`).run();
|
|
452
|
-
db2.prepare(`INSERT OR IGNORE INTO meta (key, value) VALUES ('mini_skills_generation', '0')`).run();
|
|
453
|
-
_dbCache.set(normalized, db2);
|
|
454
|
-
return db2;
|
|
455
464
|
}
|
|
456
465
|
function closeAllDatabases() {
|
|
457
466
|
for (const [key, db2] of _dbCache) {
|
|
@@ -2964,6 +2973,74 @@ var init_provider = __esm({
|
|
|
2964
2973
|
}
|
|
2965
2974
|
});
|
|
2966
2975
|
|
|
2976
|
+
// src/store/sqlite-reliability.ts
|
|
2977
|
+
function isTransientSqliteError(error) {
|
|
2978
|
+
const code = error?.code;
|
|
2979
|
+
if (typeof code === "string") {
|
|
2980
|
+
return /^SQLITE_BUSY(?:_|$)/i.test(code);
|
|
2981
|
+
}
|
|
2982
|
+
return error instanceof Error && /\bdatabase is locked\b|\bdatabase is busy\b/i.test(error.message);
|
|
2983
|
+
}
|
|
2984
|
+
function isSqliteUnavailableError(error) {
|
|
2985
|
+
return error instanceof SqliteUnavailableError || error instanceof Error && /SQLite is not available|better-sqlite3.*failed|node:sqlite.*failed|bun:sqlite.*failed/i.test(error.message);
|
|
2986
|
+
}
|
|
2987
|
+
function degradedReadError(storeName) {
|
|
2988
|
+
return new Error(`[memorix] Cannot read ${storeName}: SQLite backend unavailable (memory is not loaded)`);
|
|
2989
|
+
}
|
|
2990
|
+
function degradedWriteError(storeName) {
|
|
2991
|
+
return new Error(`[memorix] Cannot write ${storeName}: SQLite backend unavailable (degraded mode; read-only)`);
|
|
2992
|
+
}
|
|
2993
|
+
function formatSqliteFailure(error) {
|
|
2994
|
+
return error instanceof Error && error.message ? error.message : String(error);
|
|
2995
|
+
}
|
|
2996
|
+
function delay(ms) {
|
|
2997
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
2998
|
+
}
|
|
2999
|
+
async function retrySqliteBusy(operation, label) {
|
|
3000
|
+
for (let attempt = 0; ; attempt++) {
|
|
3001
|
+
try {
|
|
3002
|
+
return await operation();
|
|
3003
|
+
} catch (error) {
|
|
3004
|
+
if (!isTransientSqliteError(error) || attempt >= SQLITE_BUSY_RETRY_DELAYS_MS.length) throw error;
|
|
3005
|
+
const waitMs = SQLITE_BUSY_RETRY_DELAYS_MS[attempt];
|
|
3006
|
+
console.error(
|
|
3007
|
+
`[memorix] ${label} SQLite busy (attempt ${attempt + 1}/${SQLITE_BUSY_RETRY_DELAYS_MS.length + 1}), retrying in ${waitMs}ms`
|
|
3008
|
+
);
|
|
3009
|
+
await delay(waitMs);
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
async function initializeSqliteStore(factory, dataDir, label) {
|
|
3014
|
+
try {
|
|
3015
|
+
loadBetterSqlite3();
|
|
3016
|
+
} catch (error) {
|
|
3017
|
+
throw new SqliteUnavailableError(error);
|
|
3018
|
+
}
|
|
3019
|
+
return retrySqliteBusy(async () => {
|
|
3020
|
+
const store = factory();
|
|
3021
|
+
await store.init(dataDir);
|
|
3022
|
+
return store;
|
|
3023
|
+
}, label);
|
|
3024
|
+
}
|
|
3025
|
+
var SQLITE_BUSY_RETRY_DELAYS_MS, SqliteUnavailableError;
|
|
3026
|
+
var init_sqlite_reliability = __esm({
|
|
3027
|
+
"src/store/sqlite-reliability.ts"() {
|
|
3028
|
+
"use strict";
|
|
3029
|
+
init_esm_shims();
|
|
3030
|
+
init_sqlite_db();
|
|
3031
|
+
SQLITE_BUSY_RETRY_DELAYS_MS = [50, 150, 400, 1e3, 2500];
|
|
3032
|
+
SqliteUnavailableError = class extends Error {
|
|
3033
|
+
code = "MEMORIX_SQLITE_UNAVAILABLE";
|
|
3034
|
+
constructor(cause) {
|
|
3035
|
+
super(
|
|
3036
|
+
cause instanceof Error && cause.message ? cause.message : "[memorix] SQLite is unavailable (install a supported SQLite runtime)"
|
|
3037
|
+
);
|
|
3038
|
+
this.name = "SqliteUnavailableError";
|
|
3039
|
+
}
|
|
3040
|
+
};
|
|
3041
|
+
}
|
|
3042
|
+
});
|
|
3043
|
+
|
|
2967
3044
|
// src/store/sqlite-store.ts
|
|
2968
3045
|
var sqlite_store_exports = {};
|
|
2969
3046
|
__export(sqlite_store_exports, {
|
|
@@ -3055,6 +3132,7 @@ var init_sqlite_store = __esm({
|
|
|
3055
3132
|
"use strict";
|
|
3056
3133
|
init_esm_shims();
|
|
3057
3134
|
init_sqlite_db();
|
|
3135
|
+
init_sqlite_reliability();
|
|
3058
3136
|
init_sqlite_fts();
|
|
3059
3137
|
SqliteBackend = class {
|
|
3060
3138
|
db = null;
|
|
@@ -3332,7 +3410,9 @@ var init_sqlite_store = __esm({
|
|
|
3332
3410
|
// ── Compound atomic operation ────────────────────────────────────
|
|
3333
3411
|
async atomic(fn) {
|
|
3334
3412
|
const run = this._atomicQueue.catch(() => void 0).then(async () => {
|
|
3335
|
-
|
|
3413
|
+
await retrySqliteBusy(async () => {
|
|
3414
|
+
this.db.prepare("BEGIN IMMEDIATE").run();
|
|
3415
|
+
}, "Observation atomic write");
|
|
3336
3416
|
try {
|
|
3337
3417
|
const tx = {
|
|
3338
3418
|
loadAll: async () => this.rawLoadAll(),
|
|
@@ -3431,15 +3511,15 @@ function resetObservationStore() {
|
|
|
3431
3511
|
async function createObservationStore(dataDir) {
|
|
3432
3512
|
try {
|
|
3433
3513
|
const { SqliteBackend: SqliteBackend2 } = await Promise.resolve().then(() => (init_sqlite_store(), sqlite_store_exports));
|
|
3434
|
-
|
|
3435
|
-
await store2.init(dataDir);
|
|
3436
|
-
return store2;
|
|
3514
|
+
return await initializeSqliteStore(() => new SqliteBackend2(), dataDir, "Observation store");
|
|
3437
3515
|
} catch (err) {
|
|
3438
|
-
|
|
3516
|
+
if (!isSqliteUnavailableError(err)) throw err;
|
|
3517
|
+
const reason = formatSqliteFailure(err);
|
|
3518
|
+
console.error(`[memorix] SQLite module unavailable \u2014 degraded mode (reads/writes disabled): ${reason}`);
|
|
3519
|
+
const degraded = new DegradedBackend(reason);
|
|
3520
|
+
await degraded.init(dataDir);
|
|
3521
|
+
return degraded;
|
|
3439
3522
|
}
|
|
3440
|
-
const store = new DegradedBackend();
|
|
3441
|
-
await store.init(dataDir);
|
|
3442
|
-
return store;
|
|
3443
3523
|
}
|
|
3444
3524
|
async function initObservationStore(dataDir) {
|
|
3445
3525
|
if (_store && _storeDataDir === dataDir) {
|
|
@@ -3463,36 +3543,44 @@ var init_obs_store = __esm({
|
|
|
3463
3543
|
"src/store/obs-store.ts"() {
|
|
3464
3544
|
"use strict";
|
|
3465
3545
|
init_esm_shims();
|
|
3546
|
+
init_sqlite_reliability();
|
|
3466
3547
|
_store = null;
|
|
3467
3548
|
_storeDataDir = null;
|
|
3468
3549
|
DegradedBackend = class {
|
|
3550
|
+
constructor(reason = "SQLite runtime unavailable") {
|
|
3551
|
+
this.reason = reason;
|
|
3552
|
+
}
|
|
3553
|
+
reason;
|
|
3469
3554
|
dataDir = "";
|
|
3555
|
+
unavailableRead() {
|
|
3556
|
+
return degradedReadError("observations");
|
|
3557
|
+
}
|
|
3470
3558
|
async init(dataDir) {
|
|
3471
3559
|
this.dataDir = dataDir;
|
|
3472
3560
|
}
|
|
3473
3561
|
async loadAll() {
|
|
3474
|
-
|
|
3562
|
+
throw this.unavailableRead();
|
|
3475
3563
|
}
|
|
3476
3564
|
async loadByProject(_projectId, _options) {
|
|
3477
|
-
|
|
3565
|
+
throw this.unavailableRead();
|
|
3478
3566
|
}
|
|
3479
3567
|
async countByProject(_projectId, _options) {
|
|
3480
|
-
|
|
3568
|
+
throw this.unavailableRead();
|
|
3481
3569
|
}
|
|
3482
3570
|
async getById(_id) {
|
|
3483
|
-
|
|
3571
|
+
throw this.unavailableRead();
|
|
3484
3572
|
}
|
|
3485
3573
|
async loadIdCounter() {
|
|
3486
|
-
|
|
3574
|
+
throw this.unavailableRead();
|
|
3487
3575
|
}
|
|
3488
3576
|
async countAll() {
|
|
3489
|
-
|
|
3577
|
+
throw this.unavailableRead();
|
|
3490
3578
|
}
|
|
3491
3579
|
async listProjectIds() {
|
|
3492
|
-
|
|
3580
|
+
throw this.unavailableRead();
|
|
3493
3581
|
}
|
|
3494
3582
|
async searchLexical(_options) {
|
|
3495
|
-
|
|
3583
|
+
throw this.unavailableRead();
|
|
3496
3584
|
}
|
|
3497
3585
|
hasLexicalIndex() {
|
|
3498
3586
|
return false;
|
|
@@ -3501,25 +3589,25 @@ var init_obs_store = __esm({
|
|
|
3501
3589
|
return false;
|
|
3502
3590
|
}
|
|
3503
3591
|
async insert(_obs) {
|
|
3504
|
-
throw
|
|
3592
|
+
throw degradedWriteError("observations");
|
|
3505
3593
|
}
|
|
3506
3594
|
async update(_obs) {
|
|
3507
|
-
throw
|
|
3595
|
+
throw degradedWriteError("observations");
|
|
3508
3596
|
}
|
|
3509
3597
|
async remove(_id) {
|
|
3510
|
-
throw
|
|
3598
|
+
throw degradedWriteError("observations");
|
|
3511
3599
|
}
|
|
3512
3600
|
async bulkReplace(_obs) {
|
|
3513
|
-
throw
|
|
3601
|
+
throw degradedWriteError("observations");
|
|
3514
3602
|
}
|
|
3515
3603
|
async bulkRemoveByIds(_ids) {
|
|
3516
|
-
throw
|
|
3604
|
+
throw degradedWriteError("observations");
|
|
3517
3605
|
}
|
|
3518
3606
|
async saveIdCounter(_nextId) {
|
|
3519
|
-
throw
|
|
3607
|
+
throw degradedWriteError("observations");
|
|
3520
3608
|
}
|
|
3521
3609
|
async atomic(_fn) {
|
|
3522
|
-
throw
|
|
3610
|
+
throw degradedWriteError("observations");
|
|
3523
3611
|
}
|
|
3524
3612
|
async ensureFresh() {
|
|
3525
3613
|
return false;
|
|
@@ -3532,6 +3620,9 @@ var init_obs_store = __esm({
|
|
|
3532
3620
|
getBackendName() {
|
|
3533
3621
|
return "degraded";
|
|
3534
3622
|
}
|
|
3623
|
+
getBackendReason() {
|
|
3624
|
+
return this.reason;
|
|
3625
|
+
}
|
|
3535
3626
|
};
|
|
3536
3627
|
}
|
|
3537
3628
|
});
|
|
@@ -4761,10 +4852,10 @@ async function fetchWithRetry(url, apiKey, body, options = {}, attempt = 0, nati
|
|
|
4761
4852
|
);
|
|
4762
4853
|
}
|
|
4763
4854
|
if (options.retry !== false && (response.status === 429 || response.status >= 500) && attempt < MAX_RETRIES2) {
|
|
4764
|
-
const
|
|
4855
|
+
const delay3 = BASE_DELAY_MS * Math.pow(2, attempt);
|
|
4765
4856
|
const retryAfter = response.headers.get("retry-after");
|
|
4766
4857
|
const parsedRetryAfter = retryAfter ? parseInt(retryAfter, 10) * 1e3 : NaN;
|
|
4767
|
-
const waitMs = Number.isFinite(parsedRetryAfter) ? parsedRetryAfter :
|
|
4858
|
+
const waitMs = Number.isFinite(parsedRetryAfter) ? parsedRetryAfter : delay3;
|
|
4768
4859
|
console.error(`[memorix] Embedding API ${response.status}, retry ${attempt + 1}/${MAX_RETRIES2} in ${waitMs}ms`);
|
|
4769
4860
|
await waitForRetry(waitMs, options.signal);
|
|
4770
4861
|
return fetchWithRetry(url, apiKey, body, options, attempt + 1, nativeGemini);
|
|
@@ -55305,10 +55396,10 @@ var require_retry3 = __commonJS({
|
|
|
55305
55396
|
if (!await shouldRetryFn(err)) {
|
|
55306
55397
|
return { shouldRetry: false, config: err.config };
|
|
55307
55398
|
}
|
|
55308
|
-
const
|
|
55399
|
+
const delay3 = getNextRetryDelay(config);
|
|
55309
55400
|
err.config.retryConfig.currentRetryAttempt += 1;
|
|
55310
|
-
const backoff = config.retryBackoff ? config.retryBackoff(err,
|
|
55311
|
-
setTimeout(resolve2,
|
|
55401
|
+
const backoff = config.retryBackoff ? config.retryBackoff(err, delay3) : new Promise((resolve2) => {
|
|
55402
|
+
setTimeout(resolve2, delay3);
|
|
55312
55403
|
});
|
|
55313
55404
|
if (config.onRetryAttempt) {
|
|
55314
55405
|
await config.onRetryAttempt(err);
|
|
@@ -97094,7 +97185,7 @@ async function retryBackoff(fn, strategy) {
|
|
|
97094
97185
|
retryInterval = initialInterval * Math.pow(x2, exponent) + Math.random() * 1e3;
|
|
97095
97186
|
}
|
|
97096
97187
|
const d = Math.min(retryInterval, maxInterval);
|
|
97097
|
-
await
|
|
97188
|
+
await delay2(d);
|
|
97098
97189
|
x2++;
|
|
97099
97190
|
}
|
|
97100
97191
|
}
|
|
@@ -97115,8 +97206,8 @@ function retryIntervalFromResponse(res) {
|
|
|
97115
97206
|
}
|
|
97116
97207
|
return 0;
|
|
97117
97208
|
}
|
|
97118
|
-
async function
|
|
97119
|
-
return new Promise((resolve2) => setTimeout(resolve2,
|
|
97209
|
+
async function delay2(delay3) {
|
|
97210
|
+
return new Promise((resolve2) => setTimeout(resolve2, delay3));
|
|
97120
97211
|
}
|
|
97121
97212
|
var defaultBackoff, PermanentError, TemporaryError, codeRangeRE2;
|
|
97122
97213
|
var init_retries = __esm({
|
|
@@ -143393,7 +143484,20 @@ function normalizeMiniMaxVideoRequest(input) {
|
|
|
143393
143484
|
if (ratio !== "adaptive" && ratio !== "16:9" && ratio !== "9:16" && ratio !== "1:1") {
|
|
143394
143485
|
throw new Error("MiniMax video ratio must be adaptive, 16:9, 9:16, or 1:1");
|
|
143395
143486
|
}
|
|
143396
|
-
|
|
143487
|
+
let firstFrameImageUrl;
|
|
143488
|
+
if (input.firstFrameImageUrl !== void 0) {
|
|
143489
|
+
firstFrameImageUrl = input.firstFrameImageUrl.trim();
|
|
143490
|
+
let parsed;
|
|
143491
|
+
try {
|
|
143492
|
+
parsed = new URL(firstFrameImageUrl);
|
|
143493
|
+
} catch {
|
|
143494
|
+
throw new Error("MiniMax first-frame image must be a public HTTPS URL");
|
|
143495
|
+
}
|
|
143496
|
+
if (parsed.protocol !== "https:" || parsed.username || parsed.password || sanitizeCredentials(firstFrameImageUrl) !== firstFrameImageUrl) {
|
|
143497
|
+
throw new Error("MiniMax first-frame image must be an HTTPS URL without credentials");
|
|
143498
|
+
}
|
|
143499
|
+
}
|
|
143500
|
+
return { region, model, prompt, resolution, duration, ratio, ...firstFrameImageUrl ? { firstFrameImageUrl } : {} };
|
|
143397
143501
|
}
|
|
143398
143502
|
function videoRequestConfig(input) {
|
|
143399
143503
|
const normalized = normalizeMiniMaxVideoRequest(input);
|
|
@@ -143470,7 +143574,14 @@ async function createMiniMaxVideoTask(input, dependencies = {}) {
|
|
|
143470
143574
|
headers: videoHeaders(config.apiKey),
|
|
143471
143575
|
body: JSON.stringify({
|
|
143472
143576
|
model: config.model,
|
|
143473
|
-
content: [
|
|
143577
|
+
content: [
|
|
143578
|
+
{ type: "text", text: config.prompt },
|
|
143579
|
+
...config.firstFrameImageUrl ? [{
|
|
143580
|
+
type: "image_url",
|
|
143581
|
+
image_url: { url: config.firstFrameImageUrl },
|
|
143582
|
+
role: "first_frame"
|
|
143583
|
+
}] : []
|
|
143584
|
+
],
|
|
143474
143585
|
resolution: config.resolution,
|
|
143475
143586
|
duration: config.duration,
|
|
143476
143587
|
ratio: config.ratio
|
|
@@ -143631,10 +143742,19 @@ function parseStoredRequest(value) {
|
|
|
143631
143742
|
const duration = value.duration;
|
|
143632
143743
|
const ratio = value.ratio;
|
|
143633
143744
|
const maxBytes = value.maxBytes;
|
|
143634
|
-
if (provider2 !== "minimax" && provider2 !== "minimax-cn" || region !== "global" && region !== "cn" || model !== "MiniMax-H3" || typeof prompt !== "string" || resolution !== "2K" || duration !== 5 && duration !== 10 || ratio !== "adaptive" && ratio !== "16:9" && ratio !== "9:16" && ratio !== "1:1" || typeof maxBytes !== "number" || !Number.isSafeInteger(maxBytes) || maxBytes < 1) {
|
|
143745
|
+
if (provider2 !== "minimax" && provider2 !== "minimax-cn" || region !== "global" && region !== "cn" || model !== "MiniMax-H3" || typeof prompt !== "string" || value.firstFrameImageUrl !== void 0 && typeof value.firstFrameImageUrl !== "string" || resolution !== "2K" || duration !== 5 && duration !== 10 || ratio !== "adaptive" && ratio !== "16:9" && ratio !== "9:16" && ratio !== "1:1" || typeof maxBytes !== "number" || !Number.isSafeInteger(maxBytes) || maxBytes < 1) {
|
|
143635
143746
|
throw new Error("Media video job has an invalid request payload");
|
|
143636
143747
|
}
|
|
143637
|
-
|
|
143748
|
+
const normalized = normalizeMiniMaxVideoRequest({
|
|
143749
|
+
region,
|
|
143750
|
+
model,
|
|
143751
|
+
prompt,
|
|
143752
|
+
resolution,
|
|
143753
|
+
duration,
|
|
143754
|
+
ratio,
|
|
143755
|
+
firstFrameImageUrl: value.firstFrameImageUrl
|
|
143756
|
+
});
|
|
143757
|
+
return { provider: provider2, ...normalized, maxBytes };
|
|
143638
143758
|
}
|
|
143639
143759
|
function mediaJobIdFromMaintenance(job) {
|
|
143640
143760
|
const mediaJobId = job.payload.mediaJobId;
|
|
@@ -143646,6 +143766,7 @@ function mediaJobIdFromMaintenance(job) {
|
|
|
143646
143766
|
function toVideoRequest(request) {
|
|
143647
143767
|
return {
|
|
143648
143768
|
prompt: request.prompt,
|
|
143769
|
+
firstFrameImageUrl: request.firstFrameImageUrl,
|
|
143649
143770
|
model: request.model,
|
|
143650
143771
|
region: request.region,
|
|
143651
143772
|
resolution: request.resolution,
|
|
@@ -143737,6 +143858,7 @@ function queueMiniMaxVideoGeneration(input) {
|
|
|
143737
143858
|
region: normalized.region,
|
|
143738
143859
|
model: normalized.model,
|
|
143739
143860
|
prompt: normalized.prompt,
|
|
143861
|
+
...normalized.firstFrameImageUrl ? { firstFrameImageUrl: normalized.firstFrameImageUrl } : {},
|
|
143740
143862
|
resolution: normalized.resolution,
|
|
143741
143863
|
duration: normalized.duration,
|
|
143742
143864
|
ratio: normalized.ratio,
|