@tangle-network/agent-knowledge 14.0.2 → 15.0.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.
@@ -399,6 +399,7 @@ const transactionSchema = z.object({
399
399
  purpose: z.string().min(1),
400
400
  recoveryOwner: z.string().min(1).max(256).optional(),
401
401
  pagesDirectory: pagesDirectorySchema.optional(),
402
+ researchState: z.boolean().optional(),
402
403
  createdAt: z.string().min(1),
403
404
  entries: z.array(transactionEntrySchema).min(1)
404
405
  }).strict();
@@ -406,8 +407,8 @@ const transactionDirectionSchema = z.object({
406
407
  transactionId: z.string().uuid(),
407
408
  direction: z.literal("rollback")
408
409
  }).strict();
409
- function knowledgeFileTransactionPlanHash(entries, pagesDirectory) {
410
- const normalized = entries.map((entry) => normalizePlanEntry(entry, pagesDirectory)).sort((left, right) => left.path.localeCompare(right.path));
410
+ function knowledgeFileTransactionPlanHash(entries, pagesDirectory, researchState = false) {
411
+ const normalized = entries.map((entry) => normalizePlanEntry(entry, pagesDirectory, researchState)).sort((left, right) => left.path.localeCompare(right.path));
411
412
  if (new Set(normalized.map((entry) => entry.path)).size !== normalized.length) throw new Error("knowledge transaction plan repeats a path");
412
413
  return contentHash(normalized);
413
414
  }
@@ -420,7 +421,7 @@ async function prepareKnowledgeFileTransaction(input) {
420
421
  if (activeTransactions.length > 0) throw new Error(`knowledge file transaction is already active: ${activeTransactions.join(", ")}`);
421
422
  const paths = /* @__PURE__ */ new Set();
422
423
  const changed = (await Promise.all(input.mutations.map(async (mutation, index) => {
423
- const path = assertKnowledgeMutationPath(mutation.path, boundPagesDirectory);
424
+ const path = assertKnowledgeMutationPath(mutation.path, boundPagesDirectory, input.researchState);
424
425
  if (paths.has(path)) throw new Error(`knowledge file transaction repeats path: ${path}`);
425
426
  if (mutation.content === null && mutation.mode !== void 0) throw new Error(`deleted knowledge file cannot declare a mode: ${path}`);
426
427
  paths.add(path);
@@ -455,6 +456,7 @@ async function prepareKnowledgeFileTransaction(input) {
455
456
  purpose: input.purpose,
456
457
  ...input.recoveryOwner ? { recoveryOwner: input.recoveryOwner } : {},
457
458
  ...pagesDirectory === void 0 ? {} : { pagesDirectory },
459
+ ...input.researchState === void 0 ? {} : { researchState: input.researchState },
458
460
  createdAt: (input.now ?? (() => /* @__PURE__ */ new Date()))().toISOString(),
459
461
  entries: changed.map((item) => item.entry)
460
462
  });
@@ -489,6 +491,7 @@ async function commitKnowledgeFileMutations(input) {
489
491
  transactionRoot: input.transactionRoot,
490
492
  purpose: input.purpose,
491
493
  mutations: input.mutations,
494
+ ...input.researchState === void 0 ? {} : { researchState: input.researchState },
492
495
  ...input.pagesDirectory === void 0 ? {} : { pagesDirectory: input.pagesDirectory },
493
496
  now: input.now
494
497
  });
@@ -713,7 +716,7 @@ function assertTransactionEntries(transaction) {
713
716
  const paths = /* @__PURE__ */ new Set();
714
717
  const boundPagesDirectory = normalizePagesDirectory(transaction.pagesDirectory);
715
718
  for (const entry of transaction.entries) {
716
- const normalized = assertKnowledgeMutationPath(entry.path, boundPagesDirectory);
719
+ const normalized = assertKnowledgeMutationPath(entry.path, boundPagesDirectory, transaction.researchState);
717
720
  if (entry.path !== normalized || indexes.has(entry.index) || paths.has(entry.path)) throw new Error("knowledge file transaction has duplicate or unsafe entries");
718
721
  assertHashModePair(entry.path, "before", entry.beforeHash, entry.beforeMode);
719
722
  assertHashModePair(entry.path, "after", entry.afterHash, entry.afterMode);
@@ -721,8 +724,8 @@ function assertTransactionEntries(transaction) {
721
724
  paths.add(entry.path);
722
725
  }
723
726
  }
724
- function normalizePlanEntry(entry, pagesDirectory) {
725
- const path = assertKnowledgeMutationPath(entry.path, pagesDirectory);
727
+ function normalizePlanEntry(entry, pagesDirectory, researchState) {
728
+ const path = assertKnowledgeMutationPath(entry.path, pagesDirectory, researchState);
726
729
  assertHashModePair(path, "before", entry.beforeHash, entry.beforeMode);
727
730
  assertHashModePair(path, "after", entry.afterHash, entry.afterMode);
728
731
  return {
@@ -751,9 +754,9 @@ function assertHashModePair(path, side, hash, mode) {
751
754
  function knowledgeMutationPathPrefixes(pagesDirectory) {
752
755
  return [`${normalizePagesDirectory(pagesDirectory)}/`, "raw/"];
753
756
  }
754
- function assertKnowledgeMutationPath(path, pagesDirectory) {
757
+ function assertKnowledgeMutationPath(path, pagesDirectory, researchState = false) {
755
758
  const normalized = normalizeTransactionPath(path);
756
- if (normalized === SOURCE_REGISTRY_PATH || knowledgeMutationPathPrefixes(pagesDirectory).some((prefix) => normalized.startsWith(prefix))) return normalized;
759
+ if (normalized === SOURCE_REGISTRY_PATH || researchState && (normalized === ".agent-knowledge/events.json" || /^\.agent-knowledge\/claim-ledgers\/[^/]+\.json$/.test(normalized)) || knowledgeMutationPathPrefixes(pagesDirectory).some((prefix) => normalized.startsWith(prefix))) return normalized;
757
760
  throw new Error(`knowledge transaction contains an unsupported path: ${path}`);
758
761
  }
759
762
  function normalizeTransactionPath(path) {
@@ -4019,4 +4022,4 @@ function explainKnowledgeTarget(index, target) {
4019
4022
  //#endregion
4020
4023
  export { formatKnowledgeCitationReference as $, inspectPendingKnowledgeMutation as $t, addSourceText as A, writeJsonDurableWithinRoot as An, ResearchSourceVersionSchema as At, KB_STORE_DIR as B, claimId as Bt, gradeClaims as C, renameDurable as Cn, KnowledgePageSchema as Ct, buildKnowledgeIndex as D, writeFileDurable as Dn, ResearchClaimEvidenceSchema as Dt, verifyGradeableEvidence as E, withSafeDirectory as En, KnowledgeRelationSchema as Et, ClaimLedgerMigrationRequiredError as F, assertDeepQuestionIntegrity as Ft, KnowledgeCitationAuditError as G, materializeRegisteredClaimEvidence as Gt, assertClaimLedgerId as H, deepQuestionId as Ht, FileSystemKbStore as I, assertResearchClaimEvidenceIntegrity as It, assertKnowledgeCitationAudit as J, normalizeClaimText as Jt, KnowledgeCitationResolutionError as K, mergeClaimLedgers as Kt, KB_CLAIM_LEDGER_DIR as L, assertResearchClaimLedgerIntegrity as Lt, snapshotSourceTextInput as M, textSourceAdapter as Mn, SourceRecordSchema as Mt, sourceRegistryPath as N, KNOWLEDGE_EVENT_TYPES as Nt, writeKnowledgeIndex as O, writeFileDurableWithinRoot as On, ResearchClaimLedgerSchema as Ot, writeSourceRegistry as P, ClaimLedgerGoalConflictError as Pt, auditKnowledgeCitations as Q, acquireDurableFileLock as Qt, KB_EVENTS_PATH as R, assertTrackedClaimIntegrity as Rt, claimCheckKey as S, removeDurable as Sn, KnowledgePageInvalidationSchema as St, verdictFor as T, withSafeDescendant as Tn, KnowledgeRelationNodeSchema as Tt, buildKnowledgeGraph as U, emptyClaimLedger as Ut, MemoryKbStore as V, claimSourceHost as Vt, knowledgePageRelations as W, linkClaimContradictions as Wt, assertRunScopedCitationsResolved as X, formatFrontmatter as Xt, assertKnowledgeCitationsResolved as Y, researchSourceVersionKey as Yt, auditCurrentRunCitations as Z, parseFrontmatter as Zt, lintKnowledgeIndex as _, isMissingFile as _n, KnowledgeBaseCandidateSchema as _t, applyKnowledgeWriteBlocksFile as a, applyKnowledgeFileTransaction as an, SCAFFOLD_PAGE_BASENAMES as at, UncheckableClaimError as b, readRegularFileWithinRoot as bn, KnowledgeGraphNodeSchema as bt, KnowledgeDuplicateIntakeError as c, finishKnowledgeFileTransaction as cn, isScaffoldPath as ct, createFileRunLineageAuthority as d, rollbackKnowledgeFileTransaction as dn, loadKnowledgePages as dt, isKnowledgeMutationHeld as en, parseKnowledgeCitationReference as et, createRunScopedStores as f, DEFAULT_PAGES_DIRECTORY as fn, writeJson as ft, validateKnowledgeIndex as g, isKernelAnchoredPath as gn, DeepQuestionSchema as gt, normalizePageText as h, canonicalRelativeWithinRoot as hn, normalizeLinkTarget as ht, applyKnowledgeWriteBlocks as i, withKnowledgeRead as in, resolveRunScopedCitations as it, loadSourceRegistry as j, mediaTypeFor$1 as jn, SourceAnchorSchema as jt, addSourcePath as k, writeJsonDurable as kn, ResearchClaimRecordSchema as kt, assertKnowledgeWriteIntake as l, knowledgeFileTransactionPlanHash as ln, knowledgePageFromMarkdown as lt, detectNearDuplicatePages as m, canonicalPathsEqual as mn, extractWikilinks as mt, inspectKnowledgeIndex as n, runInKnowledgeMutationScope as nn, resolveKnowledgeCitations as nt, isSafeKnowledgePath as o, assertKnowledgeMutationPath as on, initKnowledgeBase as ot, originatedPages as p, normalizePagesDirectory as pn, WIKILINK_REGEX as pt, assertCurrentRunCitationsResolved as q, mergeTrackedClaims as qt, stringMetadata as r, withKnowledgeMutation as rn, resolveRunScopedCitation as rt, parseKnowledgeWriteBlocks as s, commitKnowledgeFileMutations as sn, isKnowledgePagePath as st, explainKnowledgeTarget as t, recoverPendingKnowledgeMutation as tn, resolveKnowledgeCitation as tt, RUN_LINEAGE_BASENAME as u, prepareKnowledgeFileTransaction as un, layoutFor as ut, CHECKABLE_RUNG_THRESHOLD as v, listRegularFilesWithinRoot as vn, KnowledgeEventSchema as vt, gradeFor as w, syncDirectory as wn, KnowledgeRelationGraphSchema as wt, assertGradeableEvidence as x, relativeWithinRoot as xn, KnowledgeIndexSchema as xt, DEADLINE_EXIT_CODE as y, readRegularFileNoFollow as yn, KnowledgeGraphEdgeSchema as yt, KB_INDEX_PATH as z, claimEvidenceId as zt };
4021
4024
 
4022
- //# sourceMappingURL=inspect-DCpUoPVb.js.map
4025
+ //# sourceMappingURL=inspect-DMZXOQYl.js.map