@opengeni/core 6.37.3 → 6.37.4-canary.45279257475001

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.
@@ -1,3 +1,4 @@
1
+ import { type FirstPartyMcpToolName, type Permission } from "@opengeni/contracts";
1
2
  import type { AgentRecord } from "@opengeni/db";
2
3
  /**
3
4
  * An agent's Memory (docs/agents.md#memory): one switch. On, the agent has its
@@ -51,8 +52,23 @@ export declare const AGENT_MEMORY_UNREADABLE_MESSAGE = "Memory is off for this a
51
52
  /** The same for a shared chat with an Only me agent, which runs as a plain chat. */
52
53
  export declare const AGENT_MEMORY_NOT_THIS_CHAT_MESSAGE = "This Only me agent's Memory is read only in its owner's Only me chats. Answer from this chat.";
53
54
  export declare function agentMemoryUnreadableMessage(access: AgentMemoryAccess): string;
55
+ /** The tool an agent's chat lists its other shared chats with. */
56
+ export declare const AGENT_LIST_CHATS_TOOL: "slack_agent_chats";
57
+ /**
58
+ * Whether a chat with this first-party selection and permission ceiling gets
59
+ * the list-chats tool: it is selected, and the ceiling can satisfy its
60
+ * registration predicate (the same table the first-party MCP server admits it
61
+ * with). A null ceiling is the default one, as the delegated token is signed.
62
+ */
63
+ export declare function agentListChatsToolAvailable(tools: readonly FirstPartyMcpToolName[], permissions: readonly Permission[] | null | undefined): boolean;
64
+ /** Whether the permission ceiling can admit the list-chats tool at all. */
65
+ export declare function agentListChatsToolPermitted(permissions: readonly Permission[] | null | undefined): boolean;
54
66
  /**
55
67
  * What an agent's chat is told about its Memory, or null when Memory is off.
56
- * The collection id is the one place it is named.
68
+ * The collection id is the one place it is named. `listChatsTool: false`
69
+ * leaves out the sentence about `slack_agent_chats`, for a chat that will not
70
+ * have that tool.
57
71
  */
58
- export declare function agentMemoryGuidance(access: AgentMemoryAccess): string | null;
72
+ export declare function agentMemoryGuidance(access: AgentMemoryAccess, options?: {
73
+ listChatsTool?: boolean;
74
+ }): string | null;
package/dist/index.js CHANGED
@@ -1,31 +1,3 @@
1
- import {
2
- EDITABLE_ARTIFACT_EXPORT_FORMATS,
3
- EDITABLE_ARTIFACT_EXPORT_MAX_DOWNLOAD_BYTES,
4
- EDITABLE_ARTIFACT_EXPORT_MAX_OPTIONS_BYTES,
5
- EditableArtifactAgentApplication,
6
- EditableArtifactCompactionPipeline,
7
- EditableArtifactDurableExportError,
8
- EditableArtifactDurableExportService,
9
- EditableArtifactGenesisPipeline,
10
- EditableArtifactOfficeImportError,
11
- InMemoryEditableArtifactStableIdFactory,
12
- InMemoryEditableArtifactStore,
13
- SystemEditableArtifactClock,
14
- describeConfiguredExportFormats,
15
- describeEditableArtifactExportFormats,
16
- editableArtifactAuthorizationRevisionPortFromPostgres,
17
- editableArtifactDurableExportStorePortFromPostgres,
18
- editableArtifactFormatMatchesModality,
19
- editableArtifactLiveReadPortFromPostgres,
20
- editableArtifactLiveTicketStorePortFromPostgres,
21
- editableArtifactMaterializationKey,
22
- editableArtifactMaterializationMimeType,
23
- editableArtifactScopeAuthorizationRevisionPortFromPostgres,
24
- editableArtifactStorePortFromPostgres,
25
- unsupportedEditableArtifactExport,
26
- validateEditableArtifactMaterializationJob,
27
- validateEditableArtifactPinnedVersion
28
- } from "./chunk-SH5QEVGO.js";
29
1
  import {
30
2
  EDITABLE_ARTIFACT_HINT_MAX_BYTES,
31
3
  EDITABLE_ARTIFACT_HINT_SUBJECT_PREFIX,
@@ -54,6 +26,34 @@ import {
54
26
  encodeEditableArtifactLiveServerWireFrame,
55
27
  inspectEditableArtifactLiveWireEnvelope
56
28
  } from "./chunk-52AHIXY4.js";
29
+ import {
30
+ EDITABLE_ARTIFACT_EXPORT_FORMATS,
31
+ EDITABLE_ARTIFACT_EXPORT_MAX_DOWNLOAD_BYTES,
32
+ EDITABLE_ARTIFACT_EXPORT_MAX_OPTIONS_BYTES,
33
+ EditableArtifactAgentApplication,
34
+ EditableArtifactCompactionPipeline,
35
+ EditableArtifactDurableExportError,
36
+ EditableArtifactDurableExportService,
37
+ EditableArtifactGenesisPipeline,
38
+ EditableArtifactOfficeImportError,
39
+ InMemoryEditableArtifactStableIdFactory,
40
+ InMemoryEditableArtifactStore,
41
+ SystemEditableArtifactClock,
42
+ describeConfiguredExportFormats,
43
+ describeEditableArtifactExportFormats,
44
+ editableArtifactAuthorizationRevisionPortFromPostgres,
45
+ editableArtifactDurableExportStorePortFromPostgres,
46
+ editableArtifactFormatMatchesModality,
47
+ editableArtifactLiveReadPortFromPostgres,
48
+ editableArtifactLiveTicketStorePortFromPostgres,
49
+ editableArtifactMaterializationKey,
50
+ editableArtifactMaterializationMimeType,
51
+ editableArtifactScopeAuthorizationRevisionPortFromPostgres,
52
+ editableArtifactStorePortFromPostgres,
53
+ unsupportedEditableArtifactExport,
54
+ validateEditableArtifactMaterializationJob,
55
+ validateEditableArtifactPinnedVersion
56
+ } from "./chunk-SH5QEVGO.js";
57
57
  import {
58
58
  EDITABLE_ARTIFACT_COMPACTION_BYTE_THRESHOLD,
59
59
  EDITABLE_ARTIFACT_COMPACTION_TRANSACTION_THRESHOLD,
@@ -41689,6 +41689,10 @@ async function moveSessionToOrgAgentVersion(deps, input) {
41689
41689
  }
41690
41690
 
41691
41691
  // src/domain/agent-memory.ts
41692
+ import {
41693
+ DEFAULT_FIRST_PARTY_MCP_PERMISSIONS as DEFAULT_FIRST_PARTY_MCP_PERMISSIONS5,
41694
+ FIRST_PARTY_TOOL_AUTHORIZATION
41695
+ } from "@opengeni/contracts";
41692
41696
  function agentMemoryAccess(agent, chat) {
41693
41697
  const collectionId = agent?.memoryCollectionId ?? null;
41694
41698
  const saveKnowledge = !(chat.private && chat.slackDm === true);
@@ -41746,14 +41750,29 @@ function agentMemoryUnreadableMessage(access) {
41746
41750
  return access.readOnlyReason === "not_owner_chat" ? AGENT_MEMORY_NOT_THIS_CHAT_MESSAGE : AGENT_MEMORY_UNREADABLE_MESSAGE;
41747
41751
  }
41748
41752
  var CONTEXT_MISSING = "When context is missing";
41749
- function agentMemoryGuidance(access) {
41753
+ var AGENT_LIST_CHATS_TOOL = "slack_agent_chats";
41754
+ function agentListChatsToolAvailable(tools, permissions) {
41755
+ if (!tools.includes(AGENT_LIST_CHATS_TOOL)) return false;
41756
+ return agentListChatsToolPermitted(permissions);
41757
+ }
41758
+ function agentListChatsToolPermitted(permissions) {
41759
+ const ceiling = permissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS5;
41760
+ const policy = FIRST_PARTY_TOOL_AUTHORIZATION[AGENT_LIST_CHATS_TOOL];
41761
+ return (policy.allOf ?? []).every(
41762
+ (permission) => ceiling.includes(permission) || ceiling.includes("workspace:admin")
41763
+ );
41764
+ }
41765
+ function agentMemoryGuidance(access, options = {}) {
41750
41766
  const dm = access.saveKnowledge ? null : "This chat is private: never save anything from it to Knowledge.";
41751
41767
  if (!access.listChats) return dm;
41752
- const chats = "check your other chats with slack_agent_chats";
41768
+ const listChatsTool = options.listChatsTool ?? true;
41769
+ const chats = `check your other chats with ${AGENT_LIST_CHATS_TOOL}`;
41753
41770
  const id = access.collectionId;
41754
- if (!id || !access.read) return [`${CONTEXT_MISSING}, ${chats}.`, dm].filter(Boolean).join(" ");
41771
+ if (!id || !access.read) {
41772
+ return [listChatsTool ? `${CONTEXT_MISSING}, ${chats}.` : null, dm].filter(Boolean).join(" ") || null;
41773
+ }
41755
41774
  const lines = [
41756
- `Your Memory is Knowledge collection ${id}. ${CONTEXT_MISSING}, search it with knowledge_search (groupId ${id}, also view needs_review; say so when you rely on an unreviewed entry), then ${chats}.`
41775
+ `Your Memory is Knowledge collection ${id}. ${CONTEXT_MISSING}, search it with knowledge_search (groupId ${id}, also view needs_review; say so when you rely on an unreviewed entry)${listChatsTool ? `, then ${chats}` : ""}.`
41757
41776
  ];
41758
41777
  if (access.write && access.saveKnowledge) {
41759
41778
  lines.push(
@@ -48940,6 +48959,7 @@ async function captureOrgAgentToolCatalog(input) {
48940
48959
  return Object.keys(catalog).length > 0 ? catalog : null;
48941
48960
  }
48942
48961
  export {
48962
+ AGENT_LIST_CHATS_TOOL,
48943
48963
  AGENT_MEMORY_NOT_THIS_CHAT_MESSAGE,
48944
48964
  AGENT_MEMORY_UNREADABLE_MESSAGE,
48945
48965
  ARCHIVE_BUNDLE_TABLE,
@@ -49219,6 +49239,8 @@ export {
49219
49239
  agentConfigParentFor,
49220
49240
  agentConnectionCurrent,
49221
49241
  agentEditableBy,
49242
+ agentListChatsToolAvailable,
49243
+ agentListChatsToolPermitted,
49222
49244
  agentMemoryAccess,
49223
49245
  agentMemoryGuidance,
49224
49246
  agentMemoryReadOnlyMessage,