@byok-sdk/core 0.4.1 → 0.4.2
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/in-memory/index.d.ts +1 -1
- package/dist/in-memory/presence.d.ts +1 -7
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -63
- package/dist/index.js.map +1 -1
- package/dist/presence.d.ts +2 -48
- package/dist/stores.d.ts +3 -4
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ export { createMutableClock, IN_MEMORY_CLOCK_EPOCH } from './clock';
|
|
|
3
3
|
export { InMemoryMailboxStore } from './mailbox';
|
|
4
4
|
export { InMemoryBoardStore } from './board';
|
|
5
5
|
export { InMemoryTruthStore } from './truth';
|
|
6
|
-
export { InMemoryPresenceStore
|
|
6
|
+
export { InMemoryPresenceStore } from './presence';
|
|
7
7
|
export { InMemoryObjectStore } from './blob';
|
|
8
8
|
export { InMemoryQuotaStore } from './quota';
|
|
9
9
|
export { InMemorySkillPackStore } from './skill-pack';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type PresenceHint, type PresenceHintInput, type PresenceStore } from '../presence';
|
|
2
2
|
import type { Clock } from '../stores';
|
|
3
3
|
import { type TenantId } from '../tenant';
|
|
4
4
|
export declare class InMemoryPresenceStore implements PresenceStore {
|
|
@@ -8,9 +8,3 @@ export declare class InMemoryPresenceStore implements PresenceStore {
|
|
|
8
8
|
read(tenant: TenantId, deviceId: string): Promise<PresenceHint | undefined>;
|
|
9
9
|
list(tenant: TenantId): Promise<readonly PresenceHint[]>;
|
|
10
10
|
}
|
|
11
|
-
export declare class InMemoryActivityStore implements ActivityStore {
|
|
12
|
-
#private;
|
|
13
|
-
constructor(clock: Clock);
|
|
14
|
-
append(tenant: TenantId, input: ActivityAppendInput): Promise<ActivityTail>;
|
|
15
|
-
read(tenant: TenantId, taskId: string): Promise<ActivityTail | undefined>;
|
|
16
|
-
}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,8 +23,8 @@ export { BOARD_STATUSES, BOARD_TRANSITIONS, isLegalBoardTransition } from './boa
|
|
|
23
23
|
export type { BoardAssignee, BoardClaimInput, BoardItem, BoardItemInput, BoardListQuery, BoardPage, BoardStatus, BoardStatusUpdateInput, BoardStore, BoardUnclaimInput, } from './board';
|
|
24
24
|
export { TRUTH_RECORD_KINDS } from './truth';
|
|
25
25
|
export type { SnapshotWriteInput, TerminalWriteInput, TruthBodyRef, TruthManifestEntry, TruthManifestQuery, TruthRecord, TruthRecordKind, TruthRecordSelector, TruthStore, } from './truth';
|
|
26
|
-
export { PRESENCE_LEVELS
|
|
27
|
-
export type {
|
|
26
|
+
export { PRESENCE_LEVELS } from './presence';
|
|
27
|
+
export type { PresenceHint, PresenceHintInput, PresenceLevel, PresenceStore, } from './presence';
|
|
28
28
|
export { CONTENT_HASH_PATTERN, OBJECT_KEY_PREFIX_PATTERN, OBJECT_STATES, OBJECT_STATE_TRANSITIONS, contentHash, isContentHash, isLegalObjectTransition, objectKeyPrefix, tenantObjectKey, } from './blob';
|
|
29
29
|
export type { ContentHash, ObjectCommitInput, ObjectKeyPrefix, ObjectListQuery, ObjectManifestEntry, ObjectManifestInput, ObjectReference, ObjectReferenceInput, ObjectState, ObjectStore, } from './blob';
|
|
30
30
|
export { STORAGE_ERROR_CODES, STORAGE_ERROR_HTTP_STATUS, STORAGE_RESERVATION_STATES, STORAGE_WRITE_KINDS, STORAGE_WRITE_POSTURES, } from './quota';
|
|
@@ -41,5 +41,5 @@ export type { DeviceProofAlgorithm, DeviceProofEnvelopeV1, DeviceProofProtectedC
|
|
|
41
41
|
export { DEVICE_ASSERTION_ALGORITHMS, DEVICE_ASSERTION_AUDIENCE_MAX_BYTES, DEVICE_ASSERTION_DEFAULT_TTL_MS, DEVICE_ASSERTION_DOMAIN_PREFIX, DEVICE_ASSERTION_MAX_TTL_MS, DEVICE_ASSERTION_SCHEMA_ID, DEVICE_ASSERTION_VERSION, DeviceAssertionClaimsSchema, DeviceAssertionEnvelopeV1Schema, deviceAssertionCanonicalClaims, deviceAssertionCanonicalJson, deviceAssertionSigningInput, parseDeviceAssertionEnvelope, verifyDeviceAssertion, } from './device-assertion';
|
|
42
42
|
export type { DeviceAssertionAlgorithm, DeviceAssertionClaims, DeviceAssertionDeviceRow, DeviceAssertionEnvelopeV1, DeviceAssertionVerifier, DeviceAssertionVerifyDeps, DeviceAssertionVerifyInput, } from './device-assertion';
|
|
43
43
|
export { NONCE_SIGNING_DOMAIN, nonceSigningBytes } from './pairing';
|
|
44
|
-
export { IN_MEMORY_CLOCK_EPOCH,
|
|
44
|
+
export { IN_MEMORY_CLOCK_EPOCH, InMemoryBoardStore, InMemoryMailboxStore, InMemoryObjectStore, InMemoryPresenceStore, InMemoryQuotaStore, InMemorySkillPackStore, InMemoryTruthStore, createInMemoryCoreStores, createInMemoryCoreCompositionWithClock, createMutableClock, } from './in-memory/index';
|
|
45
45
|
export type { InMemoryCoreComposition, InMemoryCoreOptions } from './in-memory/index';
|
package/dist/index.js
CHANGED
|
@@ -173,7 +173,6 @@ var TRUTH_RECORD_KINDS = ["task.terminal", "profile", "memory"];
|
|
|
173
173
|
|
|
174
174
|
// src/presence.ts
|
|
175
175
|
var PRESENCE_LEVELS = ["online", "thinking", "working", "error", "offline"];
|
|
176
|
-
var DEFAULT_ACTIVITY_CAPACITY = 50;
|
|
177
176
|
|
|
178
177
|
// src/blob.ts
|
|
179
178
|
var CONTENT_HASH_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
@@ -529,7 +528,6 @@ var CORE_STORE_NAMES = [
|
|
|
529
528
|
"board",
|
|
530
529
|
"truth",
|
|
531
530
|
"presence",
|
|
532
|
-
"activity",
|
|
533
531
|
"objects",
|
|
534
532
|
"quota",
|
|
535
533
|
"skillPacks"
|
|
@@ -542,7 +540,6 @@ var CORE_PORT_METHODS = {
|
|
|
542
540
|
board: ["create", "get", "list", "claim", "unclaim", "updateStatus"],
|
|
543
541
|
truth: ["writeTerminal", "writeSnapshot", "getRecord", "listManifest"],
|
|
544
542
|
presence: ["publish", "read", "list"],
|
|
545
|
-
activity: ["append", "read"],
|
|
546
543
|
objects: [
|
|
547
544
|
"putManifest",
|
|
548
545
|
"commit",
|
|
@@ -572,7 +569,6 @@ var CORE_PORT_INTERFACES = {
|
|
|
572
569
|
board: "BoardStore",
|
|
573
570
|
truth: "TruthStore",
|
|
574
571
|
presence: "PresenceStore",
|
|
575
|
-
activity: "ActivityStore",
|
|
576
572
|
objects: "ObjectStore",
|
|
577
573
|
quota: "QuotaStore",
|
|
578
574
|
skillPacks: "SkillPackStore"
|
|
@@ -938,63 +934,6 @@ var InMemoryPresenceStore = class {
|
|
|
938
934
|
return this.#clock.now().toISOString() >= expiresAt;
|
|
939
935
|
}
|
|
940
936
|
};
|
|
941
|
-
var InMemoryActivityStore = class {
|
|
942
|
-
#tails = /* @__PURE__ */ new Map();
|
|
943
|
-
#clock;
|
|
944
|
-
constructor(clock) {
|
|
945
|
-
this.#clock = clock;
|
|
946
|
-
}
|
|
947
|
-
async append(tenant, input) {
|
|
948
|
-
assertTtl(input.ttlMs);
|
|
949
|
-
const capacity = input.capacity ?? DEFAULT_ACTIVITY_CAPACITY;
|
|
950
|
-
if (!Number.isSafeInteger(capacity) || capacity <= 0) {
|
|
951
|
-
throw new ByokCoreError(
|
|
952
|
-
"activity_capacity_invalid",
|
|
953
|
-
`Activity capacity must be a positive integer, received ${String(capacity)}.`
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
if (input.details.length === 0 || !Number.isSafeInteger(input.dropped) || input.dropped < 0) {
|
|
957
|
-
throw new ByokCoreError(
|
|
958
|
-
"activity_batch_invalid",
|
|
959
|
-
"Activity batches require at least one detail and a non-negative integer dropped count."
|
|
960
|
-
);
|
|
961
|
-
}
|
|
962
|
-
const now = this.#clock.now();
|
|
963
|
-
const key = tenantKey(tenant, input.taskId);
|
|
964
|
-
const existing = this.#tails.get(key);
|
|
965
|
-
const live = existing !== void 0 && now.toISOString() < existing.expiresAt ? existing : void 0;
|
|
966
|
-
const appended = input.details.map((detail) => ({
|
|
967
|
-
at: now.toISOString(),
|
|
968
|
-
detail
|
|
969
|
-
}));
|
|
970
|
-
const entries = [...live?.entries ?? [], ...appended];
|
|
971
|
-
let dropped = (live?.dropped ?? 0) + input.dropped;
|
|
972
|
-
while (entries.length > capacity) {
|
|
973
|
-
entries.shift();
|
|
974
|
-
dropped += 1;
|
|
975
|
-
}
|
|
976
|
-
const tail = {
|
|
977
|
-
tenantId: tenant,
|
|
978
|
-
taskId: input.taskId,
|
|
979
|
-
entries,
|
|
980
|
-
dropped,
|
|
981
|
-
capacity,
|
|
982
|
-
expiresAt: new Date(now.getTime() + input.ttlMs).toISOString()
|
|
983
|
-
};
|
|
984
|
-
this.#tails.set(key, tail);
|
|
985
|
-
return tail;
|
|
986
|
-
}
|
|
987
|
-
async read(tenant, taskId) {
|
|
988
|
-
const key = tenantKey(tenant, taskId);
|
|
989
|
-
const tail = this.#tails.get(key);
|
|
990
|
-
if (tail === void 0) return void 0;
|
|
991
|
-
if (this.#clock.now().toISOString() >= tail.expiresAt) {
|
|
992
|
-
this.#tails.delete(key);
|
|
993
|
-
return void 0;
|
|
994
|
-
}
|
|
995
|
-
return tail;
|
|
996
|
-
}
|
|
997
|
-
};
|
|
998
937
|
|
|
999
938
|
// src/in-memory/board.ts
|
|
1000
939
|
var DEFAULT_LIST_LIMIT = 50;
|
|
@@ -1965,7 +1904,6 @@ function createInMemoryCoreStores(options = {}) {
|
|
|
1965
1904
|
board: new InMemoryBoardStore(clock),
|
|
1966
1905
|
truth: new InMemoryTruthStore(clock),
|
|
1967
1906
|
presence: new InMemoryPresenceStore(clock),
|
|
1968
|
-
activity: new InMemoryActivityStore(clock),
|
|
1969
1907
|
objects,
|
|
1970
1908
|
quota: new InMemoryQuotaStore(clock, objects),
|
|
1971
1909
|
skillPacks: new InMemorySkillPackStore()
|
|
@@ -1977,6 +1915,6 @@ function createInMemoryCoreCompositionWithClock() {
|
|
|
1977
1915
|
return { stores: createInMemoryCoreStores({ clock }).stores, clock };
|
|
1978
1916
|
}
|
|
1979
1917
|
|
|
1980
|
-
export { BOARD_STATUSES, BOARD_TRANSITIONS, ByokCoreError, CANONICAL_TIMESTAMP_PATTERN, CAPABILITY_DECLARATION_SCHEMA_ID, CAPABILITY_NAME_PATTERN, CONTENT_HASH_PATTERN, CORE_ERROR_CODES, CORE_NON_COMPOSITION_PORT_NAMES, CORE_PORT_INTERFACES, CORE_PORT_METHODS, CORE_STORE_NAMES, CapabilityDeclarationSchema, CoreConflictError,
|
|
1918
|
+
export { BOARD_STATUSES, BOARD_TRANSITIONS, ByokCoreError, CANONICAL_TIMESTAMP_PATTERN, CAPABILITY_DECLARATION_SCHEMA_ID, CAPABILITY_NAME_PATTERN, CONTENT_HASH_PATTERN, CORE_ERROR_CODES, CORE_NON_COMPOSITION_PORT_NAMES, CORE_PORT_INTERFACES, CORE_PORT_METHODS, CORE_STORE_NAMES, CapabilityDeclarationSchema, CoreConflictError, DEVICE_ASSERTION_ALGORITHMS, DEVICE_ASSERTION_AUDIENCE_MAX_BYTES, DEVICE_ASSERTION_DEFAULT_TTL_MS, DEVICE_ASSERTION_DOMAIN_PREFIX, DEVICE_ASSERTION_MAX_TTL_MS, DEVICE_ASSERTION_SCHEMA_ID, DEVICE_ASSERTION_VERSION, DEVICE_PROOF_ALGORITHMS, DEVICE_PROOF_DOMAIN_PREFIX, DEVICE_PROOF_HEADER, DEVICE_PROOF_SCHEMA_ID, DEVICE_PROOF_VERSION, DeviceAssertionClaimsSchema, DeviceAssertionEnvelopeV1Schema, DeviceProofEnvelopeV1Schema, DeviceProofProtectedClaimsSchema, IN_MEMORY_CLOCK_EPOCH, InMemoryBoardStore, InMemoryMailboxStore, InMemoryObjectStore, InMemoryPresenceStore, InMemoryQuotaStore, InMemorySkillPackStore, InMemoryTruthStore, MAILBOX_MESSAGE_STATES, NONCE_SIGNING_DOMAIN, OBJECT_KEY_PREFIX_PATTERN, OBJECT_STATES, OBJECT_STATE_TRANSITIONS, PRESENCE_LEVELS, PRINCIPAL_KINDS, SKILL_FRONTMATTER_FIELDS, SKILL_PACK_DESCRIPTION_MAX_LENGTH, SKILL_PACK_ENTRY_PATH, SKILL_PACK_FILE_MAX_BYTES, SKILL_PACK_FILE_PATH_MAX_LENGTH, SKILL_PACK_FILE_PATH_PATTERN, SKILL_PACK_FORBIDDEN_FIELDS, SKILL_PACK_MANIFEST_SCHEMA_ID, SKILL_PACK_MAX_BYTES, SKILL_PACK_MAX_FILES, SKILL_PACK_NAME_MAX_LENGTH, SKILL_PACK_NAME_PATTERN, SKILL_PACK_REJECTIONS, SKILL_PACK_VERSION_PATTERN, STORAGE_ERROR_CODES, STORAGE_ERROR_HTTP_STATUS, STORAGE_RESERVATION_STATES, STORAGE_WRITE_KINDS, STORAGE_WRITE_POSTURES, SkillPackFileSchema, SkillPackManifestSchema, TENANT_ID_MAX_LENGTH, TENANT_KEY_SEPARATOR, TRUTH_RECORD_KINDS, assertCanonicalTimestamp, assertCapability, canonicalizeJson, canonicalizeJsonBytes, checkSkillPackEntry, checkSkillPackFileContent, checkSkillPackManifest, contentHash, createInMemoryCoreCompositionWithClock, createInMemoryCoreStores, createMutableClock, deviceAssertionCanonicalClaims, deviceAssertionCanonicalJson, deviceAssertionSigningInput, deviceProofCanonicalClaims, deviceProofCanonicalJson, deviceProofSigningInput, hasCapability, isCanonicalTimestamp, isContentHash, isControlPlanePrincipal, isCoreConflictError, isCoreError, isDevicePrincipal, isLegalBoardTransition, isLegalObjectTransition, isSkillPackPathSafe, isTenantId, nonceSigningBytes, objectKeyPrefix, parseCapabilityDeclaration, parseDeviceAssertionEnvelope, parseDeviceProofEnvelope, parseSkillFrontmatter, parseSkillPackManifest, principalTenant, skillPackContentHashInput, tenantId, tenantKey, tenantObjectKey, verifyDeviceAssertion };
|
|
1981
1919
|
//# sourceMappingURL=index.js.map
|
|
1982
1920
|
//# sourceMappingURL=index.js.map
|