primcli 1.17.0 → 1.19.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.
|
@@ -322,8 +322,8 @@ const checkForExistence = (options, name) => {
|
|
|
322
322
|
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
|
|
323
323
|
return false;
|
|
324
324
|
};
|
|
325
|
-
|
|
326
|
-
for (const auth of security) {
|
|
325
|
+
async function setAuthParams(options) {
|
|
326
|
+
for (const auth of options.security ?? []) {
|
|
327
327
|
if (checkForExistence(options, auth.name)) continue;
|
|
328
328
|
const token = await getAuthToken(auth, options.auth);
|
|
329
329
|
if (!token) continue;
|
|
@@ -341,7 +341,7 @@ const setAuthParams = async ({ security, ...options }) => {
|
|
|
341
341
|
break;
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
}
|
|
344
|
+
}
|
|
345
345
|
const buildUrl = (options) => getUrl({
|
|
346
346
|
baseUrl: options.baseUrl,
|
|
347
347
|
path: options.path,
|
|
@@ -448,10 +448,7 @@ const createClient = (config = {}) => {
|
|
|
448
448
|
headers: mergeHeaders(_config.headers, options.headers),
|
|
449
449
|
serializedBody: void 0
|
|
450
450
|
};
|
|
451
|
-
if (opts.security) await setAuthParams(
|
|
452
|
-
...opts,
|
|
453
|
-
security: opts.security
|
|
454
|
-
});
|
|
451
|
+
if (opts.security) await setAuthParams(opts);
|
|
455
452
|
if (opts.requestValidator) await opts.requestValidator(opts);
|
|
456
453
|
if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
|
|
457
454
|
if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
|
|
@@ -462,100 +459,95 @@ const createClient = (config = {}) => {
|
|
|
462
459
|
};
|
|
463
460
|
};
|
|
464
461
|
const request = async (options) => {
|
|
465
|
-
const
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
...opts,
|
|
469
|
-
body: getValidRequestBody(opts)
|
|
470
|
-
};
|
|
471
|
-
let request = new Request(url, requestInit);
|
|
472
|
-
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
473
|
-
const _fetch = opts.fetch;
|
|
462
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
463
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
464
|
+
let request;
|
|
474
465
|
let response;
|
|
475
466
|
try {
|
|
467
|
+
const { opts, url } = await beforeRequest(options);
|
|
468
|
+
const requestInit = {
|
|
469
|
+
redirect: "follow",
|
|
470
|
+
...opts,
|
|
471
|
+
body: getValidRequestBody(opts)
|
|
472
|
+
};
|
|
473
|
+
request = new Request(url, requestInit);
|
|
474
|
+
for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
|
|
475
|
+
const _fetch = opts.fetch;
|
|
476
476
|
response = await _fetch(request);
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, void 0, request, opts);
|
|
480
|
-
finalError = finalError || {};
|
|
481
|
-
if (opts.throwOnError) throw finalError;
|
|
482
|
-
return opts.responseStyle === "data" ? void 0 : {
|
|
483
|
-
error: finalError,
|
|
477
|
+
for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
|
|
478
|
+
const result = {
|
|
484
479
|
request,
|
|
485
|
-
response
|
|
480
|
+
response
|
|
486
481
|
};
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
482
|
+
if (response.ok) {
|
|
483
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
484
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
485
|
+
let emptyData;
|
|
486
|
+
switch (parseAs) {
|
|
487
|
+
case "arrayBuffer":
|
|
488
|
+
case "blob":
|
|
489
|
+
case "text":
|
|
490
|
+
emptyData = await response[parseAs]();
|
|
491
|
+
break;
|
|
492
|
+
case "formData":
|
|
493
|
+
emptyData = new FormData();
|
|
494
|
+
break;
|
|
495
|
+
case "stream":
|
|
496
|
+
emptyData = response.body;
|
|
497
|
+
break;
|
|
498
|
+
default:
|
|
499
|
+
emptyData = {};
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
503
|
+
data: emptyData,
|
|
504
|
+
...result
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
let data;
|
|
497
508
|
switch (parseAs) {
|
|
498
509
|
case "arrayBuffer":
|
|
499
510
|
case "blob":
|
|
500
|
-
case "text":
|
|
501
|
-
emptyData = await response[parseAs]();
|
|
502
|
-
break;
|
|
503
511
|
case "formData":
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
case "stream":
|
|
507
|
-
emptyData = response.body;
|
|
512
|
+
case "text":
|
|
513
|
+
data = await response[parseAs]();
|
|
508
514
|
break;
|
|
509
|
-
|
|
510
|
-
|
|
515
|
+
case "json": {
|
|
516
|
+
const text = await response.text();
|
|
517
|
+
data = text ? JSON.parse(text) : {};
|
|
511
518
|
break;
|
|
519
|
+
}
|
|
520
|
+
case "stream": return opts.responseStyle === "data" ? response.body : {
|
|
521
|
+
data: response.body,
|
|
522
|
+
...result
|
|
523
|
+
};
|
|
512
524
|
}
|
|
513
|
-
|
|
514
|
-
data
|
|
515
|
-
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
let data;
|
|
519
|
-
switch (parseAs) {
|
|
520
|
-
case "arrayBuffer":
|
|
521
|
-
case "blob":
|
|
522
|
-
case "formData":
|
|
523
|
-
case "text":
|
|
524
|
-
data = await response[parseAs]();
|
|
525
|
-
break;
|
|
526
|
-
case "json": {
|
|
527
|
-
const text = await response.text();
|
|
528
|
-
data = text ? JSON.parse(text) : {};
|
|
529
|
-
break;
|
|
525
|
+
if (parseAs === "json") {
|
|
526
|
+
if (opts.responseValidator) await opts.responseValidator(data);
|
|
527
|
+
if (opts.responseTransformer) data = await opts.responseTransformer(data);
|
|
530
528
|
}
|
|
531
|
-
|
|
532
|
-
data
|
|
529
|
+
return opts.responseStyle === "data" ? data : {
|
|
530
|
+
data,
|
|
533
531
|
...result
|
|
534
532
|
};
|
|
535
533
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
534
|
+
const textError = await response.text();
|
|
535
|
+
let jsonError;
|
|
536
|
+
try {
|
|
537
|
+
jsonError = JSON.parse(textError);
|
|
538
|
+
} catch {}
|
|
539
|
+
throw jsonError ?? textError;
|
|
540
|
+
} catch (error) {
|
|
541
|
+
let finalError = error;
|
|
542
|
+
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
|
|
543
|
+
finalError = finalError || {};
|
|
544
|
+
if (throwOnError) throw finalError;
|
|
545
|
+
return responseStyle === "data" ? void 0 : {
|
|
546
|
+
error: finalError,
|
|
547
|
+
request,
|
|
548
|
+
response
|
|
543
549
|
};
|
|
544
550
|
}
|
|
545
|
-
const textError = await response.text();
|
|
546
|
-
let jsonError;
|
|
547
|
-
try {
|
|
548
|
-
jsonError = JSON.parse(textError);
|
|
549
|
-
} catch {}
|
|
550
|
-
const error = jsonError ?? textError;
|
|
551
|
-
let finalError = error;
|
|
552
|
-
for (const fn of interceptors.error.fns) if (fn) finalError = await fn(error, response, request, opts);
|
|
553
|
-
finalError = finalError || {};
|
|
554
|
-
if (opts.throwOnError) throw finalError;
|
|
555
|
-
return opts.responseStyle === "data" ? void 0 : {
|
|
556
|
-
error: finalError,
|
|
557
|
-
...result
|
|
558
|
-
};
|
|
559
551
|
};
|
|
560
552
|
const makeMethodFn = (method) => (options) => request({
|
|
561
553
|
...options,
|
|
@@ -566,7 +558,6 @@ const createClient = (config = {}) => {
|
|
|
566
558
|
return createSseClient({
|
|
567
559
|
...opts,
|
|
568
560
|
body: opts.body,
|
|
569
|
-
headers: opts.headers,
|
|
570
561
|
method,
|
|
571
562
|
onRequest: async (url, init) => {
|
|
572
563
|
let request = new Request(url, init);
|
package/dist/oclif/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as saveActiveChatState, C as resolveCliAuth, D as deleteChatState, E as chatStatePath, M as createClient, N as createConfig, O as loadActiveChatState, S as normalizeApiBaseUrl, T as saveSignupCredentials, _ as deleteCliCredentials, a as normalizeCliEnvironmentName, b as hasStoredCliLogin, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, g as credentialsPath, h as credentialsLockPath, i as loadCliConfig, j as PrimitiveApiClient, k as loadChatConversationByLocalId, l as saveCliConfig, m as cliAccessTokenExpiresAt, n as deleteCliConfig, o as redactCliEnvironment, p as acquireCliCredentialsLock, r as emptyCliConfig, s as removeCliEnvironment, u as upsertCliEnvironment, v as deleteCliCredentialsLock, w as saveCliCredentials, x as loadCliCredentials, y as detectPrimitiveKeyEnvMisname } from "../cli-config-
|
|
1
|
+
import { A as saveActiveChatState, C as resolveCliAuth, D as deleteChatState, E as chatStatePath, M as createClient, N as createConfig, O as loadActiveChatState, S as normalizeApiBaseUrl, T as saveSignupCredentials, _ as deleteCliCredentials, a as normalizeCliEnvironmentName, b as hasStoredCliLogin, c as resolveConfigEnvironment, d as validateCliHeaderName, f as validateCliHeaderValue, g as credentialsPath, h as credentialsLockPath, i as loadCliConfig, j as PrimitiveApiClient, k as loadChatConversationByLocalId, l as saveCliConfig, m as cliAccessTokenExpiresAt, n as deleteCliConfig, o as redactCliEnvironment, p as acquireCliCredentialsLock, r as emptyCliConfig, s as removeCliEnvironment, u as upsertCliEnvironment, v as deleteCliCredentialsLock, w as saveCliCredentials, x as loadCliCredentials, y as detectPrimitiveKeyEnvMisname } from "../cli-config-BKso8oJu.js";
|
|
2
2
|
import { Args, Command, Errors, Flags, ux } from "@oclif/core";
|
|
3
3
|
import { chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -22242,6 +22242,31 @@ const operationManifest = [
|
|
|
22242
22242
|
}
|
|
22243
22243
|
];
|
|
22244
22244
|
//#endregion
|
|
22245
|
+
//#region ../packages/api-core/src/memories.ts
|
|
22246
|
+
function isPlainJsonObject(value) {
|
|
22247
|
+
const prototype = Object.getPrototypeOf(value);
|
|
22248
|
+
return prototype === Object.prototype || prototype === null;
|
|
22249
|
+
}
|
|
22250
|
+
function isMemoryJsonValue(value, seen = /* @__PURE__ */ new Set()) {
|
|
22251
|
+
if (value === null) return true;
|
|
22252
|
+
if (typeof value === "string" || typeof value === "boolean") return true;
|
|
22253
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
22254
|
+
if (typeof value !== "object") return false;
|
|
22255
|
+
if (seen.has(value)) return false;
|
|
22256
|
+
seen.add(value);
|
|
22257
|
+
try {
|
|
22258
|
+
if (Array.isArray(value)) {
|
|
22259
|
+
for (let index = 0; index < value.length; index += 1) if (!(index in value) || !isMemoryJsonValue(value[index], seen)) return false;
|
|
22260
|
+
return true;
|
|
22261
|
+
}
|
|
22262
|
+
if (!isPlainJsonObject(value)) return false;
|
|
22263
|
+
for (const nested of Object.values(value)) if (!isMemoryJsonValue(nested, seen)) return false;
|
|
22264
|
+
return true;
|
|
22265
|
+
} finally {
|
|
22266
|
+
seen.delete(value);
|
|
22267
|
+
}
|
|
22268
|
+
}
|
|
22269
|
+
//#endregion
|
|
22245
22270
|
//#region src/oclif/api-client.ts
|
|
22246
22271
|
const API_HEADERS_ENV = "PRIMITIVE_API_HEADERS";
|
|
22247
22272
|
const OAUTH_REFRESH_SKEW_MS = 60 * 1e3;
|
|
@@ -26542,8 +26567,8 @@ const PRIMITIVE_TEAM_AUTHOR = {
|
|
|
26542
26567
|
name: "Primitive Team",
|
|
26543
26568
|
url: "https://primitive.dev"
|
|
26544
26569
|
};
|
|
26545
|
-
const SDK_VERSION_RANGE = "^1.
|
|
26546
|
-
const CLI_VERSION_RANGE = "^1.
|
|
26570
|
+
const SDK_VERSION_RANGE = "^1.19.0";
|
|
26571
|
+
const CLI_VERSION_RANGE = "^1.19.0";
|
|
26547
26572
|
const ESBUILD_VERSION_RANGE = "^0.27.0";
|
|
26548
26573
|
function renderHandler() {
|
|
26549
26574
|
return `// env.PRIMITIVE_API_KEY, env.PRIMITIVE_WEBHOOK_SECRET, and
|
|
@@ -26645,6 +26670,14 @@ function inboundRecipientDomains(event: EmailReceivedEvent): Set<string> {
|
|
|
26645
26670
|
// - Track Message-ID / In-Reply-To chains to break ping-pong loops
|
|
26646
26671
|
// between two cooperating handlers on different domains.
|
|
26647
26672
|
// - Rate-limit replies per sender per hour as a safety net.
|
|
26673
|
+
//
|
|
26674
|
+
// Loop protection is NOT sender authentication. The address matching
|
|
26675
|
+
// here is deliberately loose (it exists to avoid replying to our own
|
|
26676
|
+
// mail, where a false positive just drops one reply). If your handler
|
|
26677
|
+
// gates any privileged action on WHO sent the email, do not reuse this
|
|
26678
|
+
// logic or regex the From header yourself; use isTrustedSender from
|
|
26679
|
+
// "@primitivedotdev/sdk/api", which anchors the DMARC verdict to your
|
|
26680
|
+
// expected domain and strict-parses the From header.
|
|
26648
26681
|
export function isLoop(event: EmailReceivedEvent): boolean {
|
|
26649
26682
|
// RFC 5321: bounce notifications use the null MAIL FROM (envelope
|
|
26650
26683
|
// sender = empty string). Some MTAs report this as "<>" verbatim.
|
|
@@ -29689,6 +29722,7 @@ var LogoutCommand = class LogoutCommand extends Command {
|
|
|
29689
29722
|
};
|
|
29690
29723
|
//#endregion
|
|
29691
29724
|
//#region src/oclif/commands/memories.ts
|
|
29725
|
+
var MemoryCliInputError = class extends Error {};
|
|
29692
29726
|
const API_KEY_FLAG = Flags.string({
|
|
29693
29727
|
description: "Primitive API key override (defaults to PRIMITIVE_API_KEY or saved OAuth login credentials)",
|
|
29694
29728
|
env: "PRIMITIVE_API_KEY"
|
|
@@ -29721,11 +29755,27 @@ function printData(command, responseData) {
|
|
|
29721
29755
|
const data = responseData?.data ?? null;
|
|
29722
29756
|
command.log(JSON.stringify(data, null, 2));
|
|
29723
29757
|
}
|
|
29758
|
+
function handleMemoryInputError(error) {
|
|
29759
|
+
if (!(error instanceof MemoryCliInputError)) return false;
|
|
29760
|
+
process.stderr.write(`${error.message}\n`);
|
|
29761
|
+
process.exitCode = 1;
|
|
29762
|
+
return true;
|
|
29763
|
+
}
|
|
29764
|
+
function nonEmptyFlag(value, name) {
|
|
29765
|
+
if (value === void 0) return void 0;
|
|
29766
|
+
if (value.trim().length === 0) throw new MemoryCliInputError(`${name} must be a non-empty string.`);
|
|
29767
|
+
return value;
|
|
29768
|
+
}
|
|
29724
29769
|
function parseMemoryJson(source, label = "value") {
|
|
29725
29770
|
try {
|
|
29771
|
+
const value = JSON.parse(source);
|
|
29772
|
+
if (!isMemoryJsonValue(value)) return {
|
|
29773
|
+
kind: "error",
|
|
29774
|
+
message: `${label} must be valid JSON. Numbers must be finite, arrays must not be sparse, and values may not contain undefined, bigint, symbol, function, class instance, or cyclic entries.`
|
|
29775
|
+
};
|
|
29726
29776
|
return {
|
|
29727
29777
|
kind: "ok",
|
|
29728
|
-
value
|
|
29778
|
+
value
|
|
29729
29779
|
};
|
|
29730
29780
|
} catch (error) {
|
|
29731
29781
|
return {
|
|
@@ -29762,31 +29812,63 @@ function resolveMemoryValueSource(input) {
|
|
|
29762
29812
|
};
|
|
29763
29813
|
}
|
|
29764
29814
|
function memoryScopeForBody(flags) {
|
|
29765
|
-
|
|
29815
|
+
const functionId = nonEmptyFlag(flags.function, "--function");
|
|
29816
|
+
if (functionId !== void 0) return {
|
|
29766
29817
|
type: "function",
|
|
29767
|
-
id:
|
|
29818
|
+
id: functionId
|
|
29768
29819
|
};
|
|
29769
29820
|
if (flags.org) return { type: "org" };
|
|
29770
29821
|
}
|
|
29771
29822
|
function memoryScopeForQuery(flags) {
|
|
29772
|
-
|
|
29823
|
+
const functionId = nonEmptyFlag(flags.function, "--function");
|
|
29824
|
+
if (functionId !== void 0) return {
|
|
29773
29825
|
scope_type: "function",
|
|
29774
|
-
scope_id:
|
|
29826
|
+
scope_id: functionId
|
|
29775
29827
|
};
|
|
29776
29828
|
if (flags.org) return { scope_type: "org" };
|
|
29777
29829
|
return {};
|
|
29778
29830
|
}
|
|
29779
29831
|
function buildSetMemoryInput(params) {
|
|
29780
29832
|
const scope = memoryScopeForBody(params.flags);
|
|
29833
|
+
const expiresAt = nonEmptyFlag(params.flags["expires-at"], "--expires-at");
|
|
29834
|
+
const ifVersion = nonEmptyFlag(params.flags["if-version"], "--if-version");
|
|
29781
29835
|
return {
|
|
29782
29836
|
key: params.key,
|
|
29783
29837
|
value: params.value,
|
|
29784
29838
|
...scope ? { scope } : {},
|
|
29785
29839
|
...params.flags["ttl-seconds"] !== void 0 ? { ttl_seconds: params.flags["ttl-seconds"] } : {},
|
|
29786
|
-
...
|
|
29840
|
+
...expiresAt !== void 0 ? { expires_at: expiresAt } : {},
|
|
29787
29841
|
...params.flags["clear-ttl"] ? { clear_ttl: true } : {},
|
|
29788
29842
|
...params.flags["if-absent"] ? { if_absent: true } : {},
|
|
29789
|
-
...
|
|
29843
|
+
...ifVersion !== void 0 ? { if_version: ifVersion } : {}
|
|
29844
|
+
};
|
|
29845
|
+
}
|
|
29846
|
+
function buildGetMemoryQuery(params) {
|
|
29847
|
+
return {
|
|
29848
|
+
key: params.key,
|
|
29849
|
+
...memoryScopeForQuery(params.flags)
|
|
29850
|
+
};
|
|
29851
|
+
}
|
|
29852
|
+
function buildDeleteMemoryQuery(params) {
|
|
29853
|
+
const ifVersion = nonEmptyFlag(params.flags["if-version"], "--if-version");
|
|
29854
|
+
return {
|
|
29855
|
+
key: params.key,
|
|
29856
|
+
...memoryScopeForQuery(params.flags),
|
|
29857
|
+
...ifVersion !== void 0 ? { if_version: ifVersion } : {}
|
|
29858
|
+
};
|
|
29859
|
+
}
|
|
29860
|
+
function buildSearchMemoriesQuery(params) {
|
|
29861
|
+
const cursor = nonEmptyFlag(params.flags.cursor, "--cursor");
|
|
29862
|
+
const updatedAfter = nonEmptyFlag(params.flags["updated-after"], "--updated-after");
|
|
29863
|
+
const updatedBefore = nonEmptyFlag(params.flags["updated-before"], "--updated-before");
|
|
29864
|
+
return {
|
|
29865
|
+
...params.prefix !== void 0 ? { prefix: params.prefix } : {},
|
|
29866
|
+
limit: params.flags.limit,
|
|
29867
|
+
...cursor !== void 0 ? { cursor } : {},
|
|
29868
|
+
...params.flags["metadata-only"] ? { include_value: "false" } : {},
|
|
29869
|
+
...updatedAfter !== void 0 ? { updated_after: updatedAfter } : {},
|
|
29870
|
+
...updatedBefore !== void 0 ? { updated_before: updatedBefore } : {},
|
|
29871
|
+
...memoryScopeForQuery(params.flags)
|
|
29790
29872
|
};
|
|
29791
29873
|
}
|
|
29792
29874
|
var MemoriesSetCommand = class MemoriesSetCommand extends Command {
|
|
@@ -29857,6 +29939,17 @@ var MemoriesSetCommand = class MemoriesSetCommand extends Command {
|
|
|
29857
29939
|
process.exitCode = 1;
|
|
29858
29940
|
return;
|
|
29859
29941
|
}
|
|
29942
|
+
let body;
|
|
29943
|
+
try {
|
|
29944
|
+
body = buildSetMemoryInput({
|
|
29945
|
+
key: args.key,
|
|
29946
|
+
value: parsed.value,
|
|
29947
|
+
flags
|
|
29948
|
+
});
|
|
29949
|
+
} catch (error) {
|
|
29950
|
+
if (handleMemoryInputError(error)) return;
|
|
29951
|
+
throw error;
|
|
29952
|
+
}
|
|
29860
29953
|
const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
|
|
29861
29954
|
apiKey: flags["api-key"],
|
|
29862
29955
|
apiBaseUrl: flags["api-base-url"],
|
|
@@ -29865,11 +29958,7 @@ var MemoriesSetCommand = class MemoriesSetCommand extends Command {
|
|
|
29865
29958
|
await runWithTiming(flags.time, async () => {
|
|
29866
29959
|
const result = await setMemory({
|
|
29867
29960
|
client: apiClient.client,
|
|
29868
|
-
body
|
|
29869
|
-
key: args.key,
|
|
29870
|
-
value: parsed.value,
|
|
29871
|
-
flags
|
|
29872
|
-
}),
|
|
29961
|
+
body,
|
|
29873
29962
|
responseStyle: "fields"
|
|
29874
29963
|
});
|
|
29875
29964
|
if (result.error) {
|
|
@@ -29903,6 +29992,16 @@ var MemoriesGetCommand = class MemoriesGetCommand extends Command {
|
|
|
29903
29992
|
};
|
|
29904
29993
|
async run() {
|
|
29905
29994
|
const { args, flags } = await this.parse(MemoriesGetCommand);
|
|
29995
|
+
let query;
|
|
29996
|
+
try {
|
|
29997
|
+
query = buildGetMemoryQuery({
|
|
29998
|
+
key: args.key,
|
|
29999
|
+
flags
|
|
30000
|
+
});
|
|
30001
|
+
} catch (error) {
|
|
30002
|
+
if (handleMemoryInputError(error)) return;
|
|
30003
|
+
throw error;
|
|
30004
|
+
}
|
|
29906
30005
|
const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
|
|
29907
30006
|
apiKey: flags["api-key"],
|
|
29908
30007
|
apiBaseUrl: flags["api-base-url"],
|
|
@@ -29911,10 +30010,7 @@ var MemoriesGetCommand = class MemoriesGetCommand extends Command {
|
|
|
29911
30010
|
await runWithTiming(flags.time, async () => {
|
|
29912
30011
|
const result = await getMemory({
|
|
29913
30012
|
client: apiClient.client,
|
|
29914
|
-
query
|
|
29915
|
-
key: args.key,
|
|
29916
|
-
...memoryScopeForQuery(flags)
|
|
29917
|
-
},
|
|
30013
|
+
query,
|
|
29918
30014
|
responseStyle: "fields"
|
|
29919
30015
|
});
|
|
29920
30016
|
if (result.error) {
|
|
@@ -29950,6 +30046,16 @@ var MemoriesDeleteCommand = class MemoriesDeleteCommand extends Command {
|
|
|
29950
30046
|
};
|
|
29951
30047
|
async run() {
|
|
29952
30048
|
const { args, flags } = await this.parse(MemoriesDeleteCommand);
|
|
30049
|
+
let query;
|
|
30050
|
+
try {
|
|
30051
|
+
query = buildDeleteMemoryQuery({
|
|
30052
|
+
key: args.key,
|
|
30053
|
+
flags
|
|
30054
|
+
});
|
|
30055
|
+
} catch (error) {
|
|
30056
|
+
if (handleMemoryInputError(error)) return;
|
|
30057
|
+
throw error;
|
|
30058
|
+
}
|
|
29953
30059
|
const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
|
|
29954
30060
|
apiKey: flags["api-key"],
|
|
29955
30061
|
apiBaseUrl: flags["api-base-url"],
|
|
@@ -29958,11 +30064,7 @@ var MemoriesDeleteCommand = class MemoriesDeleteCommand extends Command {
|
|
|
29958
30064
|
await runWithTiming(flags.time, async () => {
|
|
29959
30065
|
const result = await deleteMemory({
|
|
29960
30066
|
client: apiClient.client,
|
|
29961
|
-
query
|
|
29962
|
-
key: args.key,
|
|
29963
|
-
...memoryScopeForQuery(flags),
|
|
29964
|
-
...flags["if-version"] ? { if_version: flags["if-version"] } : {}
|
|
29965
|
-
},
|
|
30067
|
+
query,
|
|
29966
30068
|
responseStyle: "fields"
|
|
29967
30069
|
});
|
|
29968
30070
|
if (result.error) {
|
|
@@ -30007,6 +30109,16 @@ var MemoriesSearchCommand = class MemoriesSearchCommand extends Command {
|
|
|
30007
30109
|
};
|
|
30008
30110
|
async run() {
|
|
30009
30111
|
const { args, flags } = await this.parse(MemoriesSearchCommand);
|
|
30112
|
+
let query;
|
|
30113
|
+
try {
|
|
30114
|
+
query = buildSearchMemoriesQuery({
|
|
30115
|
+
prefix: args.prefix,
|
|
30116
|
+
flags
|
|
30117
|
+
});
|
|
30118
|
+
} catch (error) {
|
|
30119
|
+
if (handleMemoryInputError(error)) return;
|
|
30120
|
+
throw error;
|
|
30121
|
+
}
|
|
30010
30122
|
const { apiClient, auth, baseUrlOverridden } = await createAuthenticatedCliApiClient({
|
|
30011
30123
|
apiKey: flags["api-key"],
|
|
30012
30124
|
apiBaseUrl: flags["api-base-url"],
|
|
@@ -30015,15 +30127,7 @@ var MemoriesSearchCommand = class MemoriesSearchCommand extends Command {
|
|
|
30015
30127
|
await runWithTiming(flags.time, async () => {
|
|
30016
30128
|
const result = await searchMemories({
|
|
30017
30129
|
client: apiClient.client,
|
|
30018
|
-
query
|
|
30019
|
-
...args.prefix !== void 0 ? { prefix: args.prefix } : {},
|
|
30020
|
-
limit: flags.limit,
|
|
30021
|
-
...flags.cursor ? { cursor: flags.cursor } : {},
|
|
30022
|
-
...flags["metadata-only"] ? { include_value: "false" } : {},
|
|
30023
|
-
...flags["updated-after"] ? { updated_after: flags["updated-after"] } : {},
|
|
30024
|
-
...flags["updated-before"] ? { updated_before: flags["updated-before"] } : {},
|
|
30025
|
-
...memoryScopeForQuery(flags)
|
|
30026
|
-
},
|
|
30130
|
+
query,
|
|
30027
30131
|
responseStyle: "fields"
|
|
30028
30132
|
});
|
|
30029
30133
|
if (result.error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as normalizeApiBaseUrl, c as resolveConfigEnvironment, i as loadCliConfig } from "../cli-config-
|
|
1
|
+
import { S as normalizeApiBaseUrl, c as resolveConfigEnvironment, i as loadCliConfig } from "../cli-config-BKso8oJu.js";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { homedir } from "node:os";
|
package/man/primitive.1
CHANGED
|
@@ -77,6 +77,15 @@ Scaffold a Primitive Function.
|
|
|
77
77
|
.B primitive functions deploy --name NAME --file PATH
|
|
78
78
|
Deploy a Primitive Function bundle.
|
|
79
79
|
.TP
|
|
80
|
+
.B primitive memories set KEY JSON
|
|
81
|
+
Store a durable JSON memory.
|
|
82
|
+
.TP
|
|
83
|
+
.B primitive memories get KEY
|
|
84
|
+
Read a durable memory by key.
|
|
85
|
+
.TP
|
|
86
|
+
.B primitive memories search PREFIX
|
|
87
|
+
List memories by key prefix.
|
|
88
|
+
.TP
|
|
80
89
|
.B primitive list-operations
|
|
81
90
|
Print the generated API operation manifest.
|
|
82
91
|
.TP
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primcli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|