@elisym/cli 0.21.3 → 0.22.0
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/index.js +25 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-deprecation
|
|
2
2
|
import { ReadableStream } from 'node:stream/web';
|
|
3
3
|
import { readFileSync, existsSync, readdirSync, statSync, renameSync, chmodSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { dirname, join, resolve, basename, relative, sep } from 'node:path';
|
|
5
|
-
import { SolanaPaymentStrategy, validateAgentName, RELAYS, ElisymIdentity, formatSol, formatAssetAmount, USDC_SOLANA_DEVNET, ElisymClient,
|
|
4
|
+
import { dirname, join, resolve, basename, relative, sep, extname } from 'node:path';
|
|
5
|
+
import { SolanaPaymentStrategy, validateAgentName, RELAYS, ElisymIdentity, formatSol, formatAssetAmount, USDC_SOLANA_DEVNET, ElisymClient, POLICY_D_TAG_PREFIX, KIND_LONG_FORM_ARTICLE, jobRequestKind, DEFAULT_KIND_OFFSET, toDTag, DEFAULTS, makeCensor, DEFAULT_REDACT_PATHS, POLICY_T_TAG, createSlidingWindowLimiter, getProtocolProgramId, getProtocolConfig, utf8ByteLength, LIMITS, calculateProtocolFee, decodeJobPayload, BoundedSet, KIND_JOB_FEEDBACK, NATIVE_SOL } from '@elisym/sdk';
|
|
6
6
|
import { ElisymYamlSchema, resolveInHome, resolveInProject, createAgentDir, writeYamlInitial, writeExampleSkillTemplate, writeSecrets, listAgents, loadAgent, writeYaml, agentPaths, readMediaCache, loadPoliciesFromDir, ensureGitignoreHasIrohEntry, lookupCachedUrl, newCacheEntry, writeMediaCache } from '@elisym/sdk/agent-store';
|
|
7
7
|
import { isAddress, createSolanaRpc, address } from '@solana/kit';
|
|
8
8
|
import { generateSecretKey, getPublicKey, nip19, verifyEvent } from 'nostr-tools';
|
|
@@ -2051,6 +2051,18 @@ function createLogger(options = {}) {
|
|
|
2051
2051
|
bannerLog: logWithIndent
|
|
2052
2052
|
};
|
|
2053
2053
|
}
|
|
2054
|
+
var MIME_BY_EXT = {
|
|
2055
|
+
".png": "image/png",
|
|
2056
|
+
".jpg": "image/jpeg",
|
|
2057
|
+
".jpeg": "image/jpeg",
|
|
2058
|
+
".gif": "image/gif",
|
|
2059
|
+
".webp": "image/webp",
|
|
2060
|
+
".svg": "image/svg+xml",
|
|
2061
|
+
".avif": "image/avif"
|
|
2062
|
+
};
|
|
2063
|
+
function mimeFromPath(path) {
|
|
2064
|
+
return MIME_BY_EXT[extname(path).toLowerCase()] ?? "application/octet-stream";
|
|
2065
|
+
}
|
|
2054
2066
|
var payment = new SolanaPaymentStrategy();
|
|
2055
2067
|
var LEDGER_GC_INTERVAL_MS = 60 * 60 * 1e3;
|
|
2056
2068
|
var LEDGER_RETENTION_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
@@ -4163,14 +4175,13 @@ async function cmdStart(nameArg, options = {}) {
|
|
|
4163
4175
|
}
|
|
4164
4176
|
}
|
|
4165
4177
|
}
|
|
4166
|
-
const media = new MediaService();
|
|
4167
4178
|
const mediaCache = await readMediaCache(loaded.dir);
|
|
4168
4179
|
let mediaCacheDirty = false;
|
|
4169
4180
|
const pictureUrl = await resolveMediaField(
|
|
4170
4181
|
loaded.yaml.picture,
|
|
4171
4182
|
loaded.dir,
|
|
4172
4183
|
mediaCache,
|
|
4173
|
-
|
|
4184
|
+
client.blossom,
|
|
4174
4185
|
identity,
|
|
4175
4186
|
(updated) => mediaCacheDirty = mediaCacheDirty || updated
|
|
4176
4187
|
);
|
|
@@ -4178,7 +4189,7 @@ async function cmdStart(nameArg, options = {}) {
|
|
|
4178
4189
|
loaded.yaml.banner,
|
|
4179
4190
|
loaded.dir,
|
|
4180
4191
|
mediaCache,
|
|
4181
|
-
|
|
4192
|
+
client.blossom,
|
|
4182
4193
|
identity,
|
|
4183
4194
|
(updated) => mediaCacheDirty = mediaCacheDirty || updated
|
|
4184
4195
|
);
|
|
@@ -4194,7 +4205,7 @@ async function cmdStart(nameArg, options = {}) {
|
|
|
4194
4205
|
cacheKey,
|
|
4195
4206
|
absPath,
|
|
4196
4207
|
mediaCache,
|
|
4197
|
-
|
|
4208
|
+
client.blossom,
|
|
4198
4209
|
identity,
|
|
4199
4210
|
() => mediaCacheDirty = true
|
|
4200
4211
|
);
|
|
@@ -4490,7 +4501,7 @@ function stripRpcSecrets(raw) {
|
|
|
4490
4501
|
return "[unparseable RPC URL]";
|
|
4491
4502
|
}
|
|
4492
4503
|
}
|
|
4493
|
-
async function resolveMediaField(value, agentDir, cache,
|
|
4504
|
+
async function resolveMediaField(value, agentDir, cache, blossom, identity, onCacheUpdate) {
|
|
4494
4505
|
if (!value) {
|
|
4495
4506
|
return void 0;
|
|
4496
4507
|
}
|
|
@@ -4502,7 +4513,7 @@ async function resolveMediaField(value, agentDir, cache, media, identity, onCach
|
|
|
4502
4513
|
console.warn(` ! Skipping media field "${value}": path must stay inside the agent directory.`);
|
|
4503
4514
|
return void 0;
|
|
4504
4515
|
}
|
|
4505
|
-
return uploadOrReuse(value, absPath, cache,
|
|
4516
|
+
return uploadOrReuse(value, absPath, cache, blossom, identity, () => onCacheUpdate(true));
|
|
4506
4517
|
}
|
|
4507
4518
|
function resolveInsideAgentDir(value, agentDir) {
|
|
4508
4519
|
const agentRoot = resolve(agentDir);
|
|
@@ -4513,7 +4524,7 @@ function resolveInsideAgentDir(value, agentDir) {
|
|
|
4513
4524
|
}
|
|
4514
4525
|
return candidate;
|
|
4515
4526
|
}
|
|
4516
|
-
async function uploadOrReuse(cacheKey, absPath, cache,
|
|
4527
|
+
async function uploadOrReuse(cacheKey, absPath, cache, blossom, identity, onCacheUpdate) {
|
|
4517
4528
|
try {
|
|
4518
4529
|
const cached = await lookupCachedUrl(cache, cacheKey, absPath);
|
|
4519
4530
|
if (cached) {
|
|
@@ -4522,12 +4533,12 @@ async function uploadOrReuse(cacheKey, absPath, cache, media, identity, onCacheU
|
|
|
4522
4533
|
console.log(` Uploading ${basename(absPath)}...`);
|
|
4523
4534
|
const data = readFileSync(absPath);
|
|
4524
4535
|
const sha256 = createHash("sha256").update(data).digest("hex");
|
|
4525
|
-
const blob = new Blob([data]);
|
|
4526
|
-
const
|
|
4527
|
-
cache[cacheKey] = newCacheEntry(url, sha256);
|
|
4536
|
+
const blob = new Blob([data], { type: mimeFromPath(absPath) });
|
|
4537
|
+
const descriptor = await blossom.upload(identity, blob);
|
|
4538
|
+
cache[cacheKey] = newCacheEntry(descriptor.url, sha256);
|
|
4528
4539
|
onCacheUpdate();
|
|
4529
|
-
console.log(` Uploaded: ${url}`);
|
|
4530
|
-
return url;
|
|
4540
|
+
console.log(` Uploaded: ${descriptor.url}`);
|
|
4541
|
+
return descriptor.url;
|
|
4531
4542
|
} catch (e) {
|
|
4532
4543
|
console.warn(` ! Failed to upload ${basename(absPath)}: ${e.message}`);
|
|
4533
4544
|
return void 0;
|