kagura-memory 0.14.0 → 0.14.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 +3 -2
- package/dist/cli.js +58 -28
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +47 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -22
- package/dist/index.d.ts +34 -22
- package/dist/index.js +47 -19
- package/dist/index.js.map +1 -1
- package/dist-mcp/mcp.cjs +1 -1
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -139,8 +139,9 @@ Values are read as click reads them. A choice matches exactly, as click's
|
|
|
139
139
|
(`--source-type`, `--progress`), casefolded as click folds it; a number
|
|
140
140
|
is read as Python's `int()` and `float()` read it, `1_000`, any decimal
|
|
141
141
|
digit (`١٢`, `12`) and the whitespace they skip included (a BOM is no
|
|
142
|
-
whitespace to them); an
|
|
143
|
-
`
|
|
142
|
+
whitespace to them); an id argument (`TOKEN_ID`, `INVITATION_ID`,
|
|
143
|
+
`KEY_ID`) is sent exactly, an integer however large, or a string id
|
|
144
|
+
(`rtok_…`, `winv_…`, `akey_…`, memory-cloud v0.89.0+) as typed; and an
|
|
144
145
|
out-of-range value is echoed as click converted it (`files upload
|
|
145
146
|
--importance 2` is refused as `2.0 is not in the range 0.0<=x<=1.0.`).
|
|
146
147
|
A failure prints `Error: <message>` on stderr, and a quota or plan
|
package/dist/cli.js
CHANGED
|
@@ -744,7 +744,7 @@ function normalizeUuid(value, label) {
|
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
// src/version.ts
|
|
747
|
-
var SDK_VERSION = "0.14.
|
|
747
|
+
var SDK_VERSION = "0.14.1";
|
|
748
748
|
|
|
749
749
|
// src/http.ts
|
|
750
750
|
function baseUrlFromMcp(mcpUrl) {
|
|
@@ -2360,10 +2360,12 @@ function parseIntOption(param, raw) {
|
|
|
2360
2360
|
return value;
|
|
2361
2361
|
}
|
|
2362
2362
|
var MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
|
|
2363
|
+
var STRING_ID = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
2363
2364
|
function parseIdArg(param, raw) {
|
|
2364
2365
|
const value = pyBigInt(raw);
|
|
2365
|
-
if (value
|
|
2366
|
-
|
|
2366
|
+
if (value !== void 0) return value >= -MAX_SAFE && value <= MAX_SAFE ? Number(value) : value;
|
|
2367
|
+
if (STRING_ID.test(raw)) return raw;
|
|
2368
|
+
throw new CliUsageError(`Invalid value for ${paramLabel(param)}: ${pyRepr(raw)} is not a valid integer or id.`);
|
|
2367
2369
|
}
|
|
2368
2370
|
function pathIdParam(param, value, what) {
|
|
2369
2371
|
if (value === "" || value === "." || value === "..") {
|
|
@@ -3583,6 +3585,14 @@ function readValue(r, kind, raw, at) {
|
|
|
3583
3585
|
return coerced(r, at, laxStr(value));
|
|
3584
3586
|
case "int":
|
|
3585
3587
|
return coerced(r, at, laxExactInt(raw));
|
|
3588
|
+
case "intOrStr": {
|
|
3589
|
+
const asInt = laxExactInt(raw);
|
|
3590
|
+
if (asInt.ok) return asInt.value;
|
|
3591
|
+
if (typeof value === "string") return coerced(r, at, laxStr(value));
|
|
3592
|
+
r.issue([...at, "int"], asInt.msg);
|
|
3593
|
+
r.issue([...at, "str"], "Input should be a valid string");
|
|
3594
|
+
return void 0;
|
|
3595
|
+
}
|
|
3586
3596
|
case "float": {
|
|
3587
3597
|
const result = laxFloat(raw);
|
|
3588
3598
|
return coerced(r, at, result.ok ? { ok: true, value: new PyFloat(result.value) } : result);
|
|
@@ -3660,12 +3670,12 @@ var RESOURCE_SETUP_RESPONSE = {
|
|
|
3660
3670
|
required("context_name", "str"),
|
|
3661
3671
|
required("resource_id", "str"),
|
|
3662
3672
|
required("token", "str"),
|
|
3663
|
-
required("token_id", "
|
|
3673
|
+
required("token_id", "intOrStr"),
|
|
3664
3674
|
optional("warning", nullable2("str"))
|
|
3665
3675
|
]
|
|
3666
3676
|
};
|
|
3667
3677
|
var TOKEN_FIELDS = [
|
|
3668
|
-
required("id", "
|
|
3678
|
+
required("id", "intOrStr"),
|
|
3669
3679
|
required("resource_id", "str"),
|
|
3670
3680
|
optional("description", nullable2("str")),
|
|
3671
3681
|
required("quota_events_per_hour", "int"),
|
|
@@ -9926,6 +9936,18 @@ function requireInt(value, label) {
|
|
|
9926
9936
|
}
|
|
9927
9937
|
return value;
|
|
9928
9938
|
}
|
|
9939
|
+
function requirePublicId(value, label) {
|
|
9940
|
+
if (typeof value === "string") {
|
|
9941
|
+
if (value.trim() === "") {
|
|
9942
|
+
throw new Error(`${label} must be a non-empty id, got ${JSON.stringify(value)}`);
|
|
9943
|
+
}
|
|
9944
|
+
return pathSegment(value, label, "an id");
|
|
9945
|
+
}
|
|
9946
|
+
if (typeof value === "number" || typeof value === "bigint") {
|
|
9947
|
+
return String(requireInt(value, label));
|
|
9948
|
+
}
|
|
9949
|
+
throw new Error(`${label} must be an integer or a string id, got ${JSON.stringify(value)}`);
|
|
9950
|
+
}
|
|
9929
9951
|
var DEFAULT_REST_BASE_URL = "https://memory.kagura-ai.com";
|
|
9930
9952
|
function pyUnquote(text) {
|
|
9931
9953
|
return text.replace(/(?:%[0-9A-Fa-f]{2})+/g, (run) => {
|
|
@@ -12300,15 +12322,17 @@ var WorkspaceClient = class extends KaguraRestClient {
|
|
|
12300
12322
|
/**
|
|
12301
12323
|
* Revoke a pending invitation (server returns 200 `{"success": true}`).
|
|
12302
12324
|
*
|
|
12303
|
-
* @param invitationId The
|
|
12304
|
-
*
|
|
12305
|
-
*
|
|
12325
|
+
* @param invitationId The invitation's id: an integer on servers before
|
|
12326
|
+
* memory-cloud v0.89.0, an opaque `winv_…` string from v0.89.0 on.
|
|
12327
|
+
* Pass a `bigint` for an integer past `Number.MAX_SAFE_INTEGER`: a
|
|
12328
|
+
* `number` that large may already be rounded to a different id, and is
|
|
12329
|
+
* refused, as is an empty string.
|
|
12306
12330
|
*/
|
|
12307
12331
|
async revokeInvitation(workspaceId, invitationId) {
|
|
12308
12332
|
const ws = normalizeWorkspaceId(workspaceId);
|
|
12309
12333
|
await this.request(
|
|
12310
12334
|
"DELETE",
|
|
12311
|
-
`/api/v1/workspaces/${ws}/invitations/${
|
|
12335
|
+
`/api/v1/workspaces/${ws}/invitations/${requirePublicId(invitationId, "invitationId")}`
|
|
12312
12336
|
);
|
|
12313
12337
|
}
|
|
12314
12338
|
// -------------------------------------------------------------------
|
|
@@ -12383,15 +12407,17 @@ var WorkspaceClient = class extends KaguraRestClient {
|
|
|
12383
12407
|
* set, row retained for forensics); success is 200 with a status body,
|
|
12384
12408
|
* and an already-revoked key surfaces as a uniform 404.
|
|
12385
12409
|
*
|
|
12386
|
-
* @param keyId The
|
|
12387
|
-
*
|
|
12388
|
-
*
|
|
12410
|
+
* @param keyId The key's id: an integer on servers before memory-cloud
|
|
12411
|
+
* v0.89.0, an opaque `akey_…` string from v0.89.0 on. Pass a `bigint`
|
|
12412
|
+
* for an integer past `Number.MAX_SAFE_INTEGER`: a `number` that large
|
|
12413
|
+
* may already be rounded to a different id, and is refused, as is an
|
|
12414
|
+
* empty string.
|
|
12389
12415
|
*/
|
|
12390
12416
|
async revokeMemberKey(workspaceId, userId, keyId) {
|
|
12391
12417
|
const ws = normalizeWorkspaceId(workspaceId);
|
|
12392
12418
|
await this.request(
|
|
12393
12419
|
"DELETE",
|
|
12394
|
-
`${memberPath(ws, userId)}/credentials/api-keys/${
|
|
12420
|
+
`${memberPath(ws, userId)}/credentials/api-keys/${requirePublicId(keyId, "keyId")}`
|
|
12395
12421
|
);
|
|
12396
12422
|
}
|
|
12397
12423
|
// -------------------------------------------------------------------
|
|
@@ -12727,7 +12753,7 @@ var inviteCreate = {
|
|
|
12727
12753
|
"WorkspaceClient.create_invitation"
|
|
12728
12754
|
);
|
|
12729
12755
|
deps.writeError("\u26A0 The invitation URL below is shown once \u2014 treat it as a join credential.");
|
|
12730
|
-
return `Invitation
|
|
12756
|
+
return `Invitation ${invitation.id} \u2192 ${invitation.email || "-"} (role=${invitation.role}, expires=${dateOr(invitation.expires_at, "never")})
|
|
12731
12757
|
${invitation.invitation_url || invitation.token || "(no url returned)"}`;
|
|
12732
12758
|
});
|
|
12733
12759
|
}
|
|
@@ -12762,7 +12788,7 @@ var inviteList = {
|
|
|
12762
12788
|
}
|
|
12763
12789
|
};
|
|
12764
12790
|
var inviteRevoke = {
|
|
12765
|
-
summary: "Revoke a pending invitation by its
|
|
12791
|
+
summary: "Revoke a pending invitation by its id (see `invite list`).",
|
|
12766
12792
|
args: "INVITATION_ID",
|
|
12767
12793
|
description: example("workspace invite revoke 7"),
|
|
12768
12794
|
spec: { flags: [WORKSPACE] },
|
|
@@ -12771,7 +12797,7 @@ var inviteRevoke = {
|
|
|
12771
12797
|
rejectExtraArgs(args, 1);
|
|
12772
12798
|
return runWorkspaceCommand(deps, args.values.workspace, async (client, ws) => {
|
|
12773
12799
|
await client.revokeInvitation(ws, invitationId);
|
|
12774
|
-
return `Revoked invitation
|
|
12800
|
+
return `Revoked invitation ${invitationId}`;
|
|
12775
12801
|
});
|
|
12776
12802
|
}
|
|
12777
12803
|
};
|
|
@@ -12822,7 +12848,7 @@ var createKey = {
|
|
|
12822
12848
|
return runWorkspaceCommand(deps, args.values.workspace, async (client, ws) => {
|
|
12823
12849
|
const key2 = await client.mintMemberKey(ws, userId, keyName, expiresDays);
|
|
12824
12850
|
deps.writeError("\u26A0 Save this key now \u2014 it cannot be shown again.");
|
|
12825
|
-
return `Key
|
|
12851
|
+
return `Key ${key2.id} '${key2.name}' for ${userId} (prefix=${key2.key_prefix}, expires=${dateOr(key2.expires_at, "never")})
|
|
12826
12852
|
${key2.plaintext_key || "(no plaintext returned)"}`;
|
|
12827
12853
|
});
|
|
12828
12854
|
}
|
|
@@ -12854,7 +12880,7 @@ var listKeys = {
|
|
|
12854
12880
|
}
|
|
12855
12881
|
};
|
|
12856
12882
|
var revokeKey = {
|
|
12857
|
-
summary: "Revoke a member's API key by its
|
|
12883
|
+
summary: "Revoke a member's API key by its id (see `list-keys`).",
|
|
12858
12884
|
args: "KEY_ID",
|
|
12859
12885
|
description: " Server-side this is a soft revoke \u2014 the row is kept for audit.\n\n" + example("auth revoke-key 42 --user google_1234 --yes"),
|
|
12860
12886
|
spec: {
|
|
@@ -12869,9 +12895,9 @@ var revokeKey = {
|
|
|
12869
12895
|
args.values.workspace,
|
|
12870
12896
|
async (client, ws) => {
|
|
12871
12897
|
await client.revokeMemberKey(ws, userId, keyId);
|
|
12872
|
-
return `Revoked key
|
|
12898
|
+
return `Revoked key ${keyId} of ${userId}`;
|
|
12873
12899
|
},
|
|
12874
|
-
args.flags.has("yes") ? void 0 : (ws) => `Revoke key
|
|
12900
|
+
args.flags.has("yes") ? void 0 : (ws) => `Revoke key ${keyId} of ${userId} in workspace ${ws}?`
|
|
12875
12901
|
);
|
|
12876
12902
|
}
|
|
12877
12903
|
};
|
|
@@ -14255,15 +14281,17 @@ var ResourceClient = class extends KaguraRestClient {
|
|
|
14255
14281
|
* Update a resource token's metadata. Only fields that are set are
|
|
14256
14282
|
* sent on the wire.
|
|
14257
14283
|
*
|
|
14258
|
-
* @param tokenId
|
|
14259
|
-
*
|
|
14260
|
-
*
|
|
14284
|
+
* @param tokenId The token's id: an integer on servers before
|
|
14285
|
+
* memory-cloud v0.89.0, an opaque `rtok_…` string from v0.89.0 on.
|
|
14286
|
+
* Pass a `bigint` for an integer past `Number.MAX_SAFE_INTEGER`; such
|
|
14287
|
+
* a `number` (already rounded to another id), a fractional one or an
|
|
14288
|
+
* empty string throws before anything is sent.
|
|
14261
14289
|
* @returns Updated token metadata.
|
|
14262
14290
|
* @throws KaguraResponseError when the body does not match the Python
|
|
14263
14291
|
* SDK's ResourceTokenResponse (#69).
|
|
14264
14292
|
*/
|
|
14265
14293
|
async updateToken(tokenId, options = {}) {
|
|
14266
|
-
const id =
|
|
14294
|
+
const id = requirePublicId(tokenId, "tokenId");
|
|
14267
14295
|
const body = {};
|
|
14268
14296
|
if (options.description !== void 0 && options.description !== null) {
|
|
14269
14297
|
body.description = options.description;
|
|
@@ -14279,12 +14307,14 @@ var ResourceClient = class extends KaguraRestClient {
|
|
|
14279
14307
|
/**
|
|
14280
14308
|
* Revoke (soft-delete) a resource token.
|
|
14281
14309
|
*
|
|
14282
|
-
* @param tokenId
|
|
14283
|
-
*
|
|
14284
|
-
*
|
|
14310
|
+
* @param tokenId The token's id: an integer on servers before
|
|
14311
|
+
* memory-cloud v0.89.0, an opaque `rtok_…` string from v0.89.0 on.
|
|
14312
|
+
* Pass a `bigint` for an integer past `Number.MAX_SAFE_INTEGER`; such
|
|
14313
|
+
* a `number` (already rounded to another id), a fractional one or an
|
|
14314
|
+
* empty string throws before anything is sent.
|
|
14285
14315
|
*/
|
|
14286
14316
|
async revokeToken(tokenId) {
|
|
14287
|
-
await this.request("DELETE", `/api/v1/resource-tokens/${
|
|
14317
|
+
await this.request("DELETE", `/api/v1/resource-tokens/${requirePublicId(tokenId, "tokenId")}`);
|
|
14288
14318
|
}
|
|
14289
14319
|
// -------------------------------------------------------------------
|
|
14290
14320
|
// Setup helper
|