@segmentstream/ontology 0.187.0 → 0.189.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.189.0
4
+
5
+ A staff read of a chat may ask for what the agent kept in it for staff.
6
+ `POST /api/ontology/chat/history` and the MCP tool `chat_history` take `internal: true`, which also
7
+ returns the chat's internal messages from the workspace's chat store, never sent: the agent's
8
+ `note` for staff on a turn's `reply` and the questions it could not answer
9
+ (`segmentstream__unanswered`), as events of kind `internal` with their `sessionId` and `turnId`.
10
+ Only a member or workflow whose `agent_chat:read`, within its scope, holds the private chat it
11
+ reads by its `agent_chat` id receives them. Every other read, the chat's own person's, a group's
12
+ and a search's among them, leaves them out whether it asks or not, and a read that does not ask
13
+ answers as before.
14
+
15
+ ## 0.188.0
16
+
17
+ List, search and read deployed workspace code with the current member’s explicit
18
+ `workspace_source:read` permission. Upgrade both SDKs together. Source tools run independently
19
+ of the sandbox and replace the workspace source copy.
20
+
3
21
  ## 0.187.0
4
22
 
5
23
  An ontology may declare 100 action triggers (`after(…)`), up from 50. `MAX_ACTION_TRIGGERS` is 100,
package/README.md CHANGED
@@ -1642,14 +1642,17 @@ history_recorded }`; private chats may have no URL. A receipt-write failure leav
1642
1642
  `history_recorded: false` without sending again. An older archive lacking the claim protocol
1643
1643
  cannot authorize delivery. Local provider proxies alone cannot replace the production archive.
1644
1644
 
1645
- `chat_history({ chat, before?, after?, limit? })` and `chat_search` read a chat with independent
1645
+ `chat_history({ chat, before?, after?, limit?, internal? })` and `chat_search` read a chat with independent
1646
1646
  chat authorization: a member reads the group chats they are in (the chat's `members`,
1647
1647
  like its attachments), `agent_chat:read` reads every group, and a private message is read by the
1648
1648
  participants it names. A posting service cannot read member chats. They read the workspace's
1649
1649
  `_chat_messages` once it holds the chat, with each message's `direction`, `author`, `sender`,
1650
1650
  `parts`, `files`, `reply_to`, `reactions`, `edited`, `deleted`, `delivery`, `disposition` and
1651
1651
  `reason` beside the archive's fields, and the platform's chat archive before; `after`, a revision,
1652
- reads the chat's changes since. `chat.retentionDays` (1–3650, 365 by default) sets how long the
1652
+ reads the chat's changes since. `internal: true` also returns the agent's internal messages, never
1653
+ sent (its notes for staff and the questions it could not answer), to a member or workflow whose
1654
+ `agent_chat:read` holds the private chat it reads by its `agent_chat` id, and to no other reader.
1655
+ `chat.retentionDays` (1–3650, 365 by default) sets how long the
1653
1656
  workspace keeps them. The canonical
1654
1657
  REST facade is `/api/ontology/chat/{list,history,search}`, and `send` is
1655
1658
  `POST /api/ontology/agent_chat/actions/send`, with the standard
@@ -1677,17 +1680,13 @@ remain readable. Use `segmentstream ontology member list --via PROVIDER` to find
1677
1680
 
1678
1681
  ### The workspace's code
1679
1682
 
1680
- `GET /api/ontology/agent/source[?cursor=…]` (`WORKSPACE_SOURCE_PATH`) gives the app's agent one
1681
- page of the workspace's deployed commit, to copy into its sandbox for the member it acts for. Only
1682
- the production runtime bearer token authenticates, with `X-SegmentStream-Act-As` naming an
1683
- active paired member; an API key, with delegation or not, and `X-SegmentStream-Agent-Task` are
1684
- refused. A member who is inactive, unpaired or without `workspace_source:read` gets 403
1685
- `permission_denied` before SegmentStream is called. The route forwards the cursor to
1686
- SegmentStream with the request's Vercel OIDC token, the organization and the member's id, and
1687
- answers with SegmentStream's status, body (a gzip-compressed tar archive, or a JSON error) and
1688
- `x-segmentstream-source-*` headers unchanged. Without a Vercel OIDC token it answers 503
1689
- `workspace_source_unavailable`. It logs `ontology.workspace_source.page` with the request, the
1690
- member and the commit, never a path. It is no MCP tool.
1683
+ Enable `workspaceSource` in `agent/segmentstream.json` and grant `workspace_source:read` to
1684
+ the roles allowed to inspect the deployed workspace. The agent gets
1685
+ `segmentstream__list_workspace_files`, `segmentstream__search_workspace_source` and
1686
+ `segmentstream__read_workspace_file`. The ontology checks the active member on every call. The
1687
+ platform resolves the production commit and returns paths or numbered lines. Pass the returned
1688
+ commit to pin follow-up reads. Continue listing or searching with `nextOffset`, including when a
1689
+ search page has no matches. Source queries work with the sandbox switched off.
1691
1690
 
1692
1691
  ### Agent attachments
1693
1692
 
@@ -261,8 +261,9 @@ export interface ChatMessageSearch {
261
261
  * `participantId`, row by row. A search of several chats names, by `<channel>:<chat id>`, the
262
262
  * groups the reader is in (`groupChats`), read as `groups` reads every group, and the chats the
263
263
  * ontology checked (`chats`), each read as `chat` reads the one searched. Every rule reads only
264
- * what reached the provider: never an internal row, a send still unsent, or one that failed
265
- * before the provider took it.
264
+ * what reached the provider: never a send still unsent, or one that failed before the provider
265
+ * took it, and never an internal row, unless a staff read of the one chat `chat` admits asks for
266
+ * them (`internal`).
266
267
  */
267
268
  export interface ChatMessageReader {
268
269
  readonly participantId: string | null;
@@ -270,6 +271,11 @@ export interface ChatMessageReader {
270
271
  readonly chat: boolean;
271
272
  readonly groupChats?: ReadonlyArray<string>;
272
273
  readonly chats?: ReadonlyArray<string>;
274
+ /**
275
+ * With `chat`, the chat's internal rows too, never sent: the agent's notes for staff and the
276
+ * questions it could not answer. Without `chat`, nothing.
277
+ */
278
+ readonly internal?: boolean;
273
279
  }
274
280
  export interface ChatMessagePage {
275
281
  readonly messages: ReadonlyArray<ChatMessage>;
@@ -669,14 +669,16 @@ export function sqlChatMessageStore(sql) {
669
669
  return Effect.succeed({ messages: [], nextCursor: null });
670
670
  }
671
671
  conditions.push(`(${rules.join(" OR ")})`);
672
- // Every rule reads what reached the provider: never an internal row, a send still unsent, nor
673
- // one that failed before the provider took it; a send becomes readable under the revision its
674
- // receipt takes. One the provider took and later failed stays, `failed`, and an echo a send
675
- // took over stays a change, so a reader polling after a revision sees the same chat as one
676
- // reading it whole.
672
+ // Every rule reads what reached the provider: never a send still unsent, nor one that failed
673
+ // before the provider took it; a send becomes readable under the revision its receipt takes.
674
+ // One the provider took and later failed stays, `failed`, and an echo a send took over stays a
675
+ // change, so a reader polling after a revision sees the same chat as one reading it whole. An
676
+ // internal row is no rule's, unless a staff read of the one chat it checked asks for it.
677
677
  conditions.push(`("direction" = 'inbound' OR "replaced_by" IS NOT NULL OR ("direction" = 'outbound' AND ` +
678
678
  `("status" IS NULL OR "status" IN ('sent', 'delivered', 'read') OR ` +
679
- `("status" = 'failed' AND "message_id" IS NOT NULL))))`);
679
+ `("status" = 'failed' AND "message_id" IS NOT NULL)))` +
680
+ (reader.chat && reader.internal === true ? ` OR "direction" = 'internal'` : "") +
681
+ `)`);
680
682
  return page(conditions, params, input);
681
683
  };
682
684
  const holds = (chat) => rows(chat === undefined
@@ -45,6 +45,12 @@ export type ChatArchiveTransport = (input: {
45
45
  * first: a read of the store alone (`withChatStore`).
46
46
  */
47
47
  readonly after?: string;
48
+ /**
49
+ * A staff read of one of `chats` asks for its internal messages too, never sent (the agent's
50
+ * notes for staff and the questions it could not answer), which only the workspace's chat store
51
+ * keeps. Any other read leaves them out.
52
+ */
53
+ readonly internal?: boolean;
48
54
  }) => Effect.Effect<ChatPage, ChatArchiveUnavailable | PermissionDenied | ActionRejected>;
49
55
  /**
50
56
  * The authenticated ontology service forwards its resolved member, never a caller-supplied ID.
@@ -3,8 +3,8 @@ import { HttpRouter } from "effect/unstable/http";
3
3
  import { RequestId } from "../errors.js";
4
4
  import { OntologyBackend } from "../runtime-contract.js";
5
5
  import type { RuntimeTokenVerifier } from "../runtime-identity.js";
6
- /** `GET /api/ontology/agent/source[?cursor=…]`: a page of the workspace's deployed code. */
7
- export declare const WORKSPACE_SOURCE_PATH = "/api/ontology/agent/source";
6
+ /** Query the workspace's deployed source as the active member. */
7
+ export declare const WORKSPACE_SOURCE_PATH = "/api/ontology/agent/source/query";
8
8
  /** Where the deployed ontology service reaches backend-next, as its connection calls do. */
9
9
  export interface WorkspaceSourceEnvironment {
10
10
  readonly segmentstreamUrl: string;
@@ -12,14 +12,8 @@ export interface WorkspaceSourceEnvironment {
12
12
  readonly organizationId: string;
13
13
  }
14
14
  /**
15
- * `GET /api/ontology/agent/source[?cursor=…]` (runtime): the app's agent, acting for a member,
16
- * reads the workspace's deployed code a page at a time to copy it into its sandbox. Only the
17
- * deployment's runtime token authenticates, never an API key or a task's secret; the member named
18
- * by `X-SegmentStream-Act-As` must be active, paired with the agent and hold
19
- * `workspace_source:read`, which no wildcard grants, before backend-next is called. The route
20
- * forwards the cursor with the request's Vercel OIDC token and answers with backend-next's status,
21
- * body and `x-segmentstream-source-*` headers as they are. It is no MCP tool, and it is not served
22
- * without runtime authentication or the agent's tables.
15
+ * The agent's source endpoint rechecks the current paired member's explicit permission for every
16
+ * query, then forwards it to the platform using the production deployment's OIDC identity.
23
17
  */
24
18
  export declare function workspaceSourceLayer(options: {
25
19
  readonly environment: WorkspaceSourceEnvironment;
@@ -7,13 +7,9 @@ import { identityToken } from "../operations.js";
7
7
  import { OntologyBackend } from "../runtime-contract.js";
8
8
  import { authenticateAgentRuntimeMember } from "./authentication.js";
9
9
  import { AGENT_PATH } from "./server.js";
10
- /** `GET /api/ontology/agent/source[?cursor=…]`: a page of the workspace's deployed code. */
11
- export const WORKSPACE_SOURCE_PATH = `${AGENT_PATH}/source`;
12
- /** The headers of a page that the route passes on as backend-next sent them. */
13
- const SOURCE_HEADER_PREFIX = "x-segmentstream-source-";
14
- const COMMIT_HEADER = `${SOURCE_HEADER_PREFIX}commit`;
15
- /** A page is at most a few megabytes, which backend-next reads from the workspace's repository. */
16
- const PAGE_TIMEOUT_MS = 60_000;
10
+ /** Query the workspace's deployed source as the active member. */
11
+ export const WORKSPACE_SOURCE_PATH = `${AGENT_PATH}/source/query`;
12
+ const QUERY_TIMEOUT_MS = 60_000;
17
13
  const UNAVAILABLE = "workspace_source_unavailable";
18
14
  function refusal(status, error, detail, requestId) {
19
15
  return HttpServerResponse.jsonUnsafe(errorBodyForWire({ error, detail, requestId }), {
@@ -21,37 +17,27 @@ function refusal(status, error, detail, requestId) {
21
17
  headers: { "cache-control": "no-store" },
22
18
  });
23
19
  }
24
- /**
25
- * One page of the deployed commit's files from backend-next, which admits the deployment by its
26
- * Vercel OIDC token and takes the member's id for its log only.
27
- */
28
- function fetchPage(input) {
29
- const { environment, token, member, cursor, requestId } = input;
20
+ function fetchQuery(input) {
21
+ const { environment, token, member, requestId } = input;
30
22
  const url = `${environment.segmentstreamUrl}/api/internal/v1/workspaces/` +
31
- `${encodeURIComponent(environment.workspaceId)}/ontology/source` +
32
- (cursor === null ? "" : `?cursor=${encodeURIComponent(cursor)}`);
23
+ `${encodeURIComponent(environment.workspaceId)}/ontology/source/query`;
33
24
  return Effect.tryPromise({
34
25
  try: async (signal) => {
35
26
  const response = await input.fetch(url, {
36
- method: "GET",
27
+ method: "POST",
28
+ body: input.query,
37
29
  redirect: "error",
38
30
  headers: {
31
+ "content-type": "application/json",
39
32
  "x-segmentstream-runtime-identity": token,
40
33
  "x-segmentstream-organization-id": environment.organizationId,
41
34
  "x-segmentstream-ontology-principal": member.id,
42
35
  "x-segmentstream-request-id": requestId,
43
36
  },
44
- signal: AbortSignal.any([signal, AbortSignal.timeout(PAGE_TIMEOUT_MS)]),
45
- });
46
- const headers = {};
47
- response.headers.forEach((value, name) => {
48
- if (name === "content-type" || name.startsWith(SOURCE_HEADER_PREFIX)) {
49
- headers[name] = value;
50
- }
37
+ signal: AbortSignal.any([signal, AbortSignal.timeout(QUERY_TIMEOUT_MS)]),
51
38
  });
52
39
  return {
53
40
  status: response.status,
54
- headers,
55
41
  body: new Uint8Array(await response.arrayBuffer()),
56
42
  };
57
43
  },
@@ -59,14 +45,8 @@ function fetchPage(input) {
59
45
  });
60
46
  }
61
47
  /**
62
- * `GET /api/ontology/agent/source[?cursor=…]` (runtime): the app's agent, acting for a member,
63
- * reads the workspace's deployed code a page at a time to copy it into its sandbox. Only the
64
- * deployment's runtime token authenticates, never an API key or a task's secret; the member named
65
- * by `X-SegmentStream-Act-As` must be active, paired with the agent and hold
66
- * `workspace_source:read`, which no wildcard grants, before backend-next is called. The route
67
- * forwards the cursor with the request's Vercel OIDC token and answers with backend-next's status,
68
- * body and `x-segmentstream-source-*` headers as they are. It is no MCP tool, and it is not served
69
- * without runtime authentication or the agent's tables.
48
+ * The agent's source endpoint rechecks the current paired member's explicit permission for every
49
+ * query, then forwards it to the platform using the production deployment's OIDC identity.
70
50
  */
71
51
  export function workspaceSourceLayer(options) {
72
52
  return Layer.effectDiscard(Effect.gen(function* () {
@@ -77,7 +57,7 @@ export function workspaceSourceLayer(options) {
77
57
  if (agents === undefined || verify === undefined) {
78
58
  return;
79
59
  }
80
- const page = (request) => Effect.gen(function* () {
60
+ const query = (request) => Effect.gen(function* () {
81
61
  const requestId = yield* RequestId;
82
62
  const authenticated = yield* authenticateAgentRuntimeMember({ request, agents, verify });
83
63
  if (!authenticated.ok) {
@@ -95,13 +75,16 @@ export function workspaceSourceLayer(options) {
95
75
  return refusal(503, UNAVAILABLE, "The request carries no Vercel OIDC token. The workspace's code is available to " +
96
76
  "production deployments.", requestId);
97
77
  }
98
- const cursor = new URL(request.url, "https://ontology.invalid").searchParams.get("cursor");
99
- const answered = yield* Effect.result(fetchPage({
78
+ const input = yield* Effect.result(request.text);
79
+ if (Result.isFailure(input) || !input.success || input.success.length > 8192) {
80
+ return refusal(400, "invalid_request", "Invalid source query.", requestId);
81
+ }
82
+ const answered = yield* Effect.result(fetchQuery({
100
83
  environment: options.environment,
101
84
  fetch: fetchImpl,
102
85
  token,
103
86
  member,
104
- cursor,
87
+ query: input.success,
105
88
  requestId,
106
89
  }));
107
90
  if (Result.isFailure(answered)) {
@@ -111,18 +94,16 @@ export function workspaceSourceLayer(options) {
111
94
  }));
112
95
  return refusal(503, UNAVAILABLE, "The workspace's code could not be read.", requestId);
113
96
  }
114
- const { status, headers, body } = answered.success;
115
- // The member and the commit only: never a path, a cursor or a file.
116
- yield* Effect.logInfo("ontology.workspace_source.page").pipe(Effect.annotateLogs({
97
+ const { status, body } = answered.success;
98
+ yield* Effect.logInfo("ontology.workspace_source.query").pipe(Effect.annotateLogs({
117
99
  requestId,
118
100
  memberId: member.id,
119
- commit: headers[COMMIT_HEADER] ?? null,
120
101
  }));
121
102
  return HttpServerResponse.uint8Array(body, {
122
103
  status,
123
- headers: { ...headers, "cache-control": "no-store" },
104
+ headers: { "content-type": "application/json", "cache-control": "no-store" },
124
105
  });
125
106
  });
126
- yield* router.add("GET", WORKSPACE_SOURCE_PATH, page);
107
+ yield* router.add("POST", WORKSPACE_SOURCE_PATH, query);
127
108
  }));
128
109
  }
@@ -65,8 +65,9 @@ export declare function chatMessageEvent(message: ChatMessage): {
65
65
  /**
66
66
  * Reads a chat from the workspace's chat store, `_chat_messages`, when the store holds its
67
67
  * messages, and a search of several chats once the store holds any message, the evidence that the
68
- * agent records there; each as the reader the chat archive's rule admits, row by row. Reads after
69
- * a `revision`, or before a cursor of the store, are the store's alone. Any other read goes to
70
- * `transport`, within the retention the ontology declares, `retentionDays`.
68
+ * agent records there; each as the reader the chat archive's rule admits, row by row, with the
69
+ * chat's internal messages only for a read of a chat the ontology checked that asks for them
70
+ * (`internal`). Reads after a `revision`, or before a cursor of the store, are the store's alone.
71
+ * Any other read goes to `transport`, within the retention the ontology declares, `retentionDays`.
71
72
  */
72
73
  export declare function withChatStore(transport: ChatArchiveTransport, backend: OntologyBackend["Service"], retentionDays: number | undefined): ChatArchiveTransport;
@@ -91,9 +91,10 @@ function withinRetention(input, retentionDays, now) {
91
91
  /**
92
92
  * Reads a chat from the workspace's chat store, `_chat_messages`, when the store holds its
93
93
  * messages, and a search of several chats once the store holds any message, the evidence that the
94
- * agent records there; each as the reader the chat archive's rule admits, row by row. Reads after
95
- * a `revision`, or before a cursor of the store, are the store's alone. Any other read goes to
96
- * `transport`, within the retention the ontology declares, `retentionDays`.
94
+ * agent records there; each as the reader the chat archive's rule admits, row by row, with the
95
+ * chat's internal messages only for a read of a chat the ontology checked that asks for them
96
+ * (`internal`). Reads after a `revision`, or before a cursor of the store, are the store's alone.
97
+ * Any other read goes to `transport`, within the retention the ontology declares, `retentionDays`.
97
98
  */
98
99
  export function withChatStore(transport, backend, retentionDays) {
99
100
  return (input) => Effect.gen(function* () {
@@ -129,13 +130,17 @@ export function withChatStore(transport, backend, retentionDays) {
129
130
  return yield* new ActionRejected({ message: "invalid_chat_search" });
130
131
  }
131
132
  // One chat's reader is decided for the chat; several chats' row by row, by each row's chat.
133
+ // Only a read of one chat the ontology checked may ask for its internal messages too.
134
+ const checked = key !== undefined && (chats ?? []).includes(key);
135
+ const internal = checked && input.internal === true ? { internal: true } : {};
132
136
  const reader = key !== undefined
133
137
  ? service
134
- ? { participantId: null, groups: false, chat: (chats ?? []).includes(key) }
138
+ ? { participantId: null, groups: false, chat: checked, ...internal }
135
139
  : {
136
140
  participantId: principal.id,
137
141
  groups: isAllowed("agent_chat:read", principal) || (memberGroups ?? []).includes(key),
138
- chat: (chats ?? []).includes(key),
142
+ chat: checked,
143
+ ...internal,
139
144
  }
140
145
  : service
141
146
  ? { participantId: null, groups: false, chat: false, chats: chats ?? [] }
@@ -95,9 +95,9 @@ export function chatReads(backend, options) {
95
95
  return yield* new ActionRejected({ message: "The chat archive is not configured." });
96
96
  }
97
97
  const key = `${registered.provider}:${registered.externalId}`;
98
- // Staff read the chat's messages whoever wrote them; its person reads the messages they
99
- // took part in, as in any private chat, so an account paired with someone else since
100
- // shows the earlier person nothing newer.
98
+ // Staff read the chat's messages whoever wrote them, and on request its internal ones;
99
+ // its person reads the messages they took part in, as in any private chat, so an account
100
+ // paired with someone else since shows the earlier person nothing newer.
101
101
  return yield* chatHistory({
102
102
  principal,
103
103
  identityToken,
@@ -108,7 +108,9 @@ export function chatReads(backend, options) {
108
108
  ...(input.limit === undefined ? {} : { limit: input.limit }),
109
109
  },
110
110
  memberGroups: [],
111
- ...(registered.staff ? { chats: [key] } : {}),
111
+ ...(registered.staff
112
+ ? { chats: [key], ...(input.internal === true ? { internal: true } : {}) }
113
+ : {}),
112
114
  ...after,
113
115
  });
114
116
  }
@@ -73,6 +73,11 @@ export declare const ChatHistory: Schema.Struct<{
73
73
  */
74
74
  readonly after: Schema.optionalKey<Schema.String>;
75
75
  readonly limit: Schema.optionalKey<Schema.Int>;
76
+ /**
77
+ * A staff read's request for more than reached the provider: the chat's internal messages too,
78
+ * each never sent. A read that may not have them reads the chat as without it.
79
+ */
80
+ readonly internal: Schema.optionalKey<Schema.Boolean>;
76
81
  }>;
77
82
  export declare const ChatDestination: Schema.Struct<{
78
83
  readonly id: Schema.String;
@@ -25,6 +25,16 @@ export const ChatHistory = Schema.Struct({
25
25
  */
26
26
  after: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^\d{1,18}$/))),
27
27
  limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 200 }))),
28
+ /**
29
+ * A staff read's request for more than reached the provider: the chat's internal messages too,
30
+ * each never sent. A read that may not have them reads the chat as without it.
31
+ */
32
+ internal: Schema.optionalKey(Schema.Boolean.annotate({
33
+ description: "Also return the chat's internal messages (kind internal), which were never sent: the " +
34
+ "agent's notes for staff on its replies and the questions it could not answer. Only for " +
35
+ "a private chat read by its agent_chat id with agent_chat:read within your scope; any " +
36
+ "other read leaves them out.",
37
+ })),
28
38
  });
29
39
  export const ChatDestination = Schema.Struct({
30
40
  id: Id,
@@ -11,7 +11,7 @@ import { nameToWire } from "../authoring-names.js";
11
11
  import { bundledNavigationCatalog } from "../navigation-artifact.js";
12
12
  import { parsePageCatalog } from "../navigation-catalog.js";
13
13
  import { chatRetentionDaysOf, declaredChatRetentionDaysOf, guestOf, signUpOriginsOf, signUpRolesOf, } from "../manifest.js";
14
- import { allowsAction } from "../permissions.js";
14
+ import { allowsAction, isAllowed, WORKSPACE_SOURCE_PERMISSION } from "../permissions.js";
15
15
  import { agentToolsFor } from "../runtime/guests.js";
16
16
  import { implicitMemberOf } from "../role.js";
17
17
  import { sqlServiceRuntime } from "../runtime/service-binding.js";
@@ -433,7 +433,12 @@ export function createOntologyService(ontology, config) {
433
433
  decide: config.decisions,
434
434
  }), oauth);
435
435
  // Every answer that tells the agent whom it acts for names the agent's own tools they hold.
436
- const agentTools = (principal) => agentToolsFor(ontology, principal);
436
+ const agentTools = (principal) => {
437
+ const tools = agentToolsFor(ontology, principal);
438
+ return principal.kind === "member" && isAllowed(WORKSPACE_SOURCE_PERMISSION, principal)
439
+ ? [...tools, "workspace_source"]
440
+ : tools;
441
+ };
437
442
  const guest = guestOf(ontology.manifest);
438
443
  // A guest proves an address with the app's own code email, which needs the production app.
439
444
  const emailCodes = config.emailCodes ??
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.187.0",
3
+ "version": "0.189.0",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",