@getmodus/sdk 0.11.0 → 0.13.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 +50 -3
- package/dist/{_client-base-DdnxB9JA.d.cts → _client-base-CGqIZtrm.d.cts} +492 -214
- package/dist/{_client-base-DdnxB9JA.d.ts → _client-base-CGqIZtrm.d.ts} +492 -214
- package/dist/{chunk-JVTQBBMZ.js → chunk-KX2P3TAH.js} +64 -23
- package/dist/chunk-KX2P3TAH.js.map +1 -0
- package/dist/{chunk-3MHHVC6C.cjs → chunk-RK4NLJIN.cjs} +64 -23
- package/dist/chunk-RK4NLJIN.cjs.map +1 -0
- package/dist/index.cjs +128 -174
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -46
- package/dist/index.d.ts +21 -46
- package/dist/index.js +12 -58
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +272 -261
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +27 -6
- package/dist/management/index.d.ts +27 -6
- package/dist/management/index.js +16 -5
- package/dist/management/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3MHHVC6C.cjs.map +0 -1
- package/dist/chunk-JVTQBBMZ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_generated/resources/management/workflows.ts","../../src/_query.ts","../../src/_generated/resources/management/workflows/interfaces.ts","../../src/management/workflows/interfaces.ts","../../src/management/workflows/agents.ts","../../src/types/context.ts","../../src/management/context/_content-merge.ts","../../src/_generated/resources/management/context/dashboards.ts","../../src/_generated/resources/management/context/dashboards/elements.ts","../../src/management/context/dashboards.ts","../../src/management/context/files.ts","../../src/_generated/resources/management/context/files.ts","../../src/management/context/items.ts","../../src/management/context/context.ts","../../src/_generated/resources/management/scopes.ts","../../src/management/_access-config.ts","../../src/_generated/resources/management/scopes/memories.ts","../../src/management/scopes/memories.ts","../../src/management/scopes/evaluations.ts","../../src/_generated/resources/management/scopes/evaluations.ts","../../src/_generated/resources/management/scopes/interfaces.ts","../../src/management/scopes/interfaces.ts","../../src/_generated/resources/management/scopes/supervision.ts","../../src/management/scopes/supervision.ts","../../src/management/scopes/skills.ts","../../src/_generated/resources/management/usage.ts","../../src/management/usage.ts","../../src/_generated/resources/management/tools.ts","../../src/management/tools.ts","../../src/management/users.ts","../../src/management/index.ts"],"sourcesContent":["// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../../_request.js'\nimport { validateId, validatePageSize } from '../../../_validation.js'\nimport type { VariationView } from '../../../types/views.js'\nimport type { Workflow, WorkflowType } from '../../../types/workflows.js'\n\n/** Generated base for the management `workflows` resource. */\nexport class WorkflowsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List workflows.\n *\n * Returns a paginated page of workflows the caller can at least `use`. Workflows the caller\n * cannot see are filtered out. Pagination uses an opaque token returned in `nextPageToken`.\n *\n * **Requires:** `workflows:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @param options.search - Case-insensitive substring filter on workflow name.\n * @param options.type - Filter by workflow type.\n * @param options.view - Variation view. `active` reads the deployed version. `draft` reads the\n * latest builder snapshot. `published` reads only a published workflow of type workflow that\n * you can use; tasks are excluded.\n * @param options.includeVariation - Include the requested variation payload (`trigger`,\n * `workflowStructure`, `agentSelection`) on list rows.\n * @returns A page of workflows.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * for await (const wf of (await mgmt.workflows.list({ search: 'digest' })).autoPagingIter()) {\n * console.log(wf.id, wf.name, wf.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n type?: WorkflowType\n view?: VariationView\n includeVariation?: boolean\n } = {}): Promise<Page<Workflow>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.search, options.type, options.view, options.includeVariation)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n type?: WorkflowType,\n view?: VariationView,\n includeVariation?: boolean,\n ): Promise<Page<Workflow>> {\n const extra: Record<string, string | boolean> = {}\n if (search !== undefined) extra.search = search\n if (type !== undefined) extra.type = type\n if (view !== undefined) extra.view = view\n if (includeVariation !== undefined) extra.includeVariation = includeVariation\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'WorkflowsController_list', {\n query: aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'workflows',\n (raw) => raw as Workflow,\n (token) => this.listPage(pageSize, token, search, type, view, includeVariation),\n )\n }\n\n /**\n * Delete a workflow.\n *\n * Deletes a workflow and stops its schedule. The workflow can be restored later with POST\n * /workflows/{id}/restore. Returns 404 if the workflow does not exist or is already deleted.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.workflows.delete('PLACEHOLDER_WORKFLOW_ID')\n * ```\n */\n async delete(workflowId: number | string): Promise<void> {\n validateId(workflowId, 'workflow_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowsController_delete', {\n pathParams: { id: workflowId },\n })\n }\n\n /**\n * Restore a deleted workflow.\n *\n * Restores a previously deleted workflow and returns it. The workflow’s schedule is not resumed\n * automatically — re-enable it if it should run again. Restoring an active workflow returns it\n * unchanged.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n */\n async restore(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_restore', {\n pathParams: { id: workflowId },\n jsonBody: {},\n })\n return data as Workflow\n }\n\n /**\n * Cancel ownership transfer.\n *\n * Cancels a pending ownership transfer. The current owner may cancel; the pending recipient may\n * decline.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n */\n async cancelOwnershipTransfer(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_cancelOwnershipTransfer', {\n pathParams: { id: workflowId },\n })\n return data as Workflow\n }\n\n /**\n * Accept ownership transfer.\n *\n * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n */\n async acceptOwnershipTransfer(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_acceptOwnershipTransfer', {\n pathParams: { id: workflowId },\n jsonBody: {},\n })\n return data as Workflow\n }\n}\n","import { ValidationError } from './_exceptions.js'\n\nexport function updateMaskQuery(\n updateMask?: string,\n): Record<string, string> | undefined {\n if (updateMask === undefined) return undefined\n if (!updateMask.trim()) {\n throw new ValidationError('update_mask must be a non-empty comma-separated list of field names')\n }\n return { updateMask }\n}\n\n/**\n * A PATCH body: the fields the caller set, plus `null` for each masked field left unset.\n *\n * The server writes only fields that are both in the mask and present in the body, so a masked\n * field left unset must go on the wire as `null` to be cleared. A nested mask path\n * (`accessConfig.visibility`) never nulls its root object.\n */\nexport function updateBody(fields: object, updateMask?: string): Record<string, unknown> {\n const body: Record<string, unknown> = Object.fromEntries(\n Object.entries(fields).filter(([, value]) => value !== undefined),\n )\n for (const field of updateMask?.split(',') ?? []) {\n const name = field.trim()\n if (name && !name.includes('.') && !(name in body)) body[name] = null\n }\n return body\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type { AgentInterface } from '../../../../management/workflows/interfaces.js'\n\n/** Generated base for the management `workflows.interfaces` resource. */\nexport class WorkflowsInterfacesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly workflowId: number | string,\n ) {}\n\n /**\n * List interfaces attached to a workflow.\n *\n * Returns every Slack, MCP, or Teams interface bound to the workflow. Requires manage permission\n * on the workflow: returns 403 if you can only use it, and 404 if you cannot access it.\n *\n * **Requires:** `workflows:read`\n */\n async list(): Promise<AgentInterface[]> {\n validateId(this.workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_list', {\n pathParams: { id: this.workflowId },\n })\n return (data as { interfaces: AgentInterface[] }).interfaces\n }\n\n /**\n * Remove every interface from a workflow.\n *\n * Deletes all interface rows attached to the workflow. Useful when recreating the interface set\n * from scratch.\n *\n * **Requires:** `workflows:write`\n */\n async deleteAll(): Promise<void> {\n validateId(this.workflowId, 'workflow_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_deleteAll', {\n pathParams: { id: this.workflowId },\n })\n }\n\n /**\n * Remove a workflow interface.\n *\n * Deletes one interface row. For MCP interfaces, bound MCP tokens are revoked best-effort.\n *\n * **Requires:** `workflows:write`\n *\n * @param interfaceId - Interface row id (UUID).\n */\n async delete(interfaceId: string): Promise<void> {\n validateId(this.workflowId, 'workflow_id')\n validateId(interfaceId, 'interface_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_delete', {\n pathParams: { id: this.workflowId, interfaceId },\n })\n }\n}\n","import { WorkflowsInterfacesResourceBase } from '../../_generated/resources/management/workflows/interfaces.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { components } from '../../_generated/v1.js'\n\nexport type AgentInterface = components['schemas']['AgentInterfaceDto']\nexport type AddAgentInterface = components['schemas']['AddAgentInterfaceDto']\nexport type UpdateAgentInterface = components['schemas']['UpdateAgentInterfaceDto']\n\nexport class WorkflowInterfacesResource extends WorkflowsInterfacesResourceBase {\n\n /**\n * Add an interface to this workflow.\n *\n * @param options - Interface configuration to attach.\n * @returns The created interface.\n */\n async create(options: AddAgentInterface): Promise<AgentInterface> {\n validateId(this.workflowId, 'workflow_id')\n return await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_add', {\n pathParams: { id: this.workflowId },\n jsonBody: omitUndefined(options),\n }) as AgentInterface\n }\n\n /**\n * Update an interface attached to this workflow.\n *\n * @param interfaceId - Interface id.\n * @param options - Updated interface values.\n * @param updateMask - Optional comma-separated field names to update.\n * @returns The updated interface.\n */\n async update(interfaceId: string, options: UpdateAgentInterface, updateMask?: string): Promise<AgentInterface> {\n validateId(this.workflowId, 'workflow_id')\n validateId(interfaceId, 'interface_id')\n return await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_update', {\n pathParams: { id: this.workflowId, interfaceId },\n query: updateMaskQuery(updateMask),\n jsonBody: updateBody(options, updateMask),\n }) as AgentInterface\n }\n}\n","import { WorkflowsResourceBase } from '../../_generated/resources/management/workflows.js'\nimport type { OperationId } from '../../_generated/operations.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { Workflow, WorkflowType } from '../../types/workflows.js'\nimport type { VariationView } from '../../types/views.js'\nimport { WorkflowInterfacesResource } from './interfaces.js'\n\nexport type TriggerInput = Record<string, unknown>\nexport type AgentSelectionInput = Record<string, unknown>\nexport type WorkflowGraphInput = Record<string, unknown>\n\n/** The canonical `/api/v1/workflows` management operationIds. */\ninterface ManagementWorkflowsOperations {\n readonly list: OperationId\n readonly get: OperationId\n readonly create: OperationId\n readonly update: OperationId\n readonly deploy: OperationId\n readonly delete: OperationId\n readonly restore: OperationId\n readonly requestOwnershipTransfer: OperationId\n readonly cancelOwnershipTransfer: OperationId\n readonly acceptOwnershipTransfer: OperationId\n readonly toggle: OperationId\n}\n\nconst MANAGEMENT_WORKFLOW_OPERATIONS: ManagementWorkflowsOperations = {\n list: 'WorkflowsController_list',\n get: 'WorkflowsController_get',\n create: 'WorkflowsController_create',\n update: 'WorkflowsController_update',\n deploy: 'WorkflowsController_deploy',\n delete: 'WorkflowsController_delete',\n restore: 'WorkflowsController_restore',\n requestOwnershipTransfer: 'WorkflowsController_requestOwnershipTransfer',\n cancelOwnershipTransfer: 'WorkflowsController_cancelOwnershipTransfer',\n acceptOwnershipTransfer: 'WorkflowsController_acceptOwnershipTransfer',\n toggle: 'WorkflowsController_toggle',\n}\n\nfunction parseWorkflow(raw: unknown): Workflow {\n return raw as Workflow\n}\n\nexport interface CreateWorkflowOptions {\n name: string\n type: WorkflowType\n description?: string\n trigger?: TriggerInput\n agentSelection?: AgentSelectionInput\n workflowStructure?: WorkflowGraphInput\n}\n\n/** @deprecated Use `CreateWorkflowOptions` instead. */\nexport type CreateAgentOptions = CreateWorkflowOptions\n\nexport interface UpdateWorkflowOptions {\n name?: string\n type?: WorkflowType\n description?: string\n trigger?: TriggerInput\n agentSelection?: AgentSelectionInput\n workflowStructure?: WorkflowGraphInput\n updateMask?: string\n}\n\n/** @deprecated Use `UpdateWorkflowOptions` instead. */\nexport type UpdateAgentOptions = UpdateWorkflowOptions\n\nexport class ManagementWorkflowsResource extends WorkflowsResourceBase {\n protected readonly ops: ManagementWorkflowsOperations = MANAGEMENT_WORKFLOW_OPERATIONS\n\n /**\n * Retrieve a workflow with full configuration.\n *\n * @param workflowId - Numeric workflow id.\n * @param options.view - Variation view: `\"active\"` (deployed), `\"draft\"`, or `\"published\"` (published workflow you can use).\n * @returns The workflow.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const [first] = (await mgmt.workflows.list()).items\n * const wf = await mgmt.workflows.get(first.id)\n * console.log(wf.name, wf.status)\n * ```\n */\n async get(workflowId: number | string, options: { view?: VariationView } = {}): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const query = options.view !== undefined ? { view: options.view } : undefined\n const data = await invokeWithRetry(this.config, this.http, this.ops.get, {\n pathParams: { id: workflowId },\n query,\n })\n return parseWorkflow(data)\n }\n\n /**\n * Interfaces attached to a workflow.\n *\n * @param workflowId - Workflow id.\n * @returns An interfaces resource scoped to the workflow.\n */\n interfaces(workflowId: number | string): WorkflowInterfacesResource {\n return new WorkflowInterfacesResource(this.http, this.config, workflowId)\n }\n\n /**\n * Create a new workflow in the organization.\n *\n * @param options.name - Display name for the workflow.\n * @param options.type - `\"workflow\"`. `\"task\"` is a deprecated alias the server stores as `\"workflow\"`.\n * @param options.trigger - Optional trigger configuration.\n * @returns The created workflow (draft).\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const wf = await mgmt.workflows.create({ name: 'Daily report', type: 'workflow' })\n * ```\n */\n async create(options: CreateWorkflowOptions): Promise<Workflow> {\n const body = omitUndefined({\n name: options.name,\n type: options.type,\n description: options.description,\n trigger: options.trigger,\n agentSelection: options.agentSelection,\n workflowStructure: options.workflowStructure,\n })\n const data = await invokeWithRetry(this.config, this.http, this.ops.create, {\n jsonBody: body,\n })\n return parseWorkflow(data)\n }\n\n /**\n * Update a workflow's configuration.\n *\n * Only the fields you pass are changed. To clear a field, name it in\n * `updateMask` and leave its argument unset: it is sent as `null`.\n *\n * @param workflowId - Numeric workflow id.\n * @param options.type - Only `\"workflow\"` is accepted; `\"task\"` is rejected with a 422.\n * @param options.updateMask - Comma-separated field names to update or clear.\n * @returns The updated workflow.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const wf = await mgmt.workflows.update('PLACEHOLDER_WORKFLOW_ID', { description: 'Runs every morning' })\n * ```\n */\n async update(workflowId: number | string, options: UpdateWorkflowOptions = {}): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const fields = {\n name: options.name,\n type: options.type,\n description: options.description,\n trigger: options.trigger,\n agentSelection: options.agentSelection,\n workflowStructure: options.workflowStructure,\n }\n const body = updateBody(fields, options.updateMask)\n const data = await invokeWithRetry(this.config, this.http, this.ops.update, {\n pathParams: { id: workflowId },\n query: updateMaskQuery(options.updateMask),\n jsonBody: body,\n })\n return parseWorkflow(data)\n }\n\n /**\n * Publish the current draft of a workflow.\n *\n * @param workflowId - Workflow id.\n * @returns The published workflow.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.workflows.update('PLACEHOLDER_WORKFLOW_ID', { description: 'Runs every morning' })\n * const published = await mgmt.workflows.deploy('PLACEHOLDER_WORKFLOW_ID')\n * ```\n */\n async deploy(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, this.ops.deploy, {\n pathParams: { id: workflowId },\n jsonBody: {},\n }),\n )\n return parseWorkflow(data.workflow)\n }\n\n /**\n * Enable or disable a workflow without deleting it.\n *\n * @param workflowId - Workflow id.\n * @param options.active - `true` to activate, `false` to deactivate.\n * @returns The updated workflow.\n */\n async toggle(workflowId: number | string, options: { active: boolean }): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, this.ops.toggle, {\n pathParams: { id: workflowId },\n jsonBody: { active: options.active },\n })\n return parseWorkflow(data)\n }\n\n /**\n * Start transferring ownership of a workflow to another organization member.\n *\n * @param workflowId - Workflow id.\n * @param options.newOwnerUserId - User id of the proposed new owner.\n * @returns The workflow with a pending ownership transfer.\n */\n async requestOwnershipTransfer(\n workflowId: number | string,\n options: { newOwnerUserId: string },\n ): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(\n this.config,\n this.http,\n this.ops.requestOwnershipTransfer,\n {\n pathParams: { id: workflowId },\n jsonBody: omitUndefined({ newOwnerUserId: options.newOwnerUserId }),\n },\n )\n return parseWorkflow(data)\n }\n}\n","import type { components } from '../_generated/v1.js'\n\nexport type ContextItem = components['schemas']['ContextItemDto']\nexport type ContextItemAncestor = components['schemas']['ContextItemAncestorDto']\nexport type ContextItemLookupRow = components['schemas']['LookupContextItemRowDto']\nexport type ContextItemsQuery = components['schemas']['QueryContextItemsRequestDto']\nexport type ContextItemsQueryResult = components['schemas']['QueryContextItemsResponseDto']\nexport type ContextItemDeletion = components['schemas']['DeleteContextItemResponseDto']\nexport type ContextItemMove = components['schemas']['MoveContextItemResponseDto']\n/** Input for `updateAccess()`; all three settings replace the current ones. */\nexport type UpdateContextItemAccessInput = components['schemas']['UpdateContextItemAccessDto']\n/** Who can view and manage an item after `updateAccess()`. */\nexport type ContextItemAccessUpdate = components['schemas']['ContextItemAccessResponseDto']\n/** Create response; ``uid`` mirrors ``contextItemId`` for list/get parity. */\nexport type CreatedContextItem = components['schemas']['CreatedContextItemResponseDto'] & {\n uid: string\n}\nexport type ContextType = string\n\nexport function withCreatedUid(\n data: components['schemas']['CreatedContextItemResponseDto'],\n): CreatedContextItem {\n return { ...data, uid: data.contextItemId }\n}\n","import { ValidationError } from '../../_exceptions.js'\nimport type { ContextItem } from '../../types/context.js'\nimport type { ManagementContextItemsResource } from './items.js'\n\nexport type UserFeedback = 'positive' | 'neutral' | 'negative'\n\nfunction requireContentDict(item: ContextItem, contextType: string): Record<string, unknown> {\n if (item.contextType !== contextType) {\n throw new ValidationError(`Expected contextType ${contextType}, got ${item.contextType}.`)\n }\n if (!item.content || typeof item.content !== 'object' || Array.isArray(item.content)) {\n throw new ValidationError(`Context item ${item.uid} has no object content; cannot merge ${contextType} fields.`)\n }\n return item.content as Record<string, unknown>\n}\n\nexport function mergeNoteContent(\n existing: Record<string, unknown>,\n options: { title: string; body: string },\n): Record<string, unknown> {\n return { ...existing, title: options.title, content: options.body }\n}\n\nexport function mergeLinkContent(\n existing: Record<string, unknown>,\n options: { title?: string; url?: string },\n): Record<string, unknown> {\n const merged = { ...existing }\n if (options.title !== undefined) merged.title = options.title\n if (options.url !== undefined) merged.url = options.url\n return merged\n}\n\nexport function mergeSavedQueryContent(\n existing: Record<string, unknown>,\n options: {\n name: string\n query: string\n connectionId?: string\n path?: string[]\n },\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...existing, name: options.name, query: options.query }\n if (options.connectionId !== undefined) merged.connectionId = options.connectionId\n if (options.path !== undefined) merged.path = options.path\n return merged\n}\n\nasync function resolveExistingContent(\n items: ManagementContextItemsResource,\n uid: string,\n contextType: string,\n existing?: ContextItem,\n): Promise<Record<string, unknown>> {\n const item = existing ?? (await items.get(uid))\n return requireContentDict(item, contextType)\n}\n\nexport async function updateWithMergedContent(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n contextType: string\n mergedContent: Record<string, unknown>\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n if (options.existing) requireContentDict(options.existing, options.contextType)\n return items.update(uid, {\n contextType: options.contextType,\n content: options.mergedContent,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n\nexport async function resolveAndUpdateNote(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n title: string\n body: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n const content = await resolveExistingContent(items, uid, 'note', options.existing)\n return updateWithMergedContent(items, uid, {\n contextType: 'note',\n mergedContent: mergeNoteContent(content, { title: options.title, body: options.body }),\n existing: options.existing,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n\nexport async function resolveAndUpdateSavedQuery(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n name: string\n query: string\n connectionId?: string\n path?: string[]\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n const content = await resolveExistingContent(items, uid, 'saved_query', options.existing)\n return updateWithMergedContent(items, uid, {\n contextType: 'saved_query',\n mergedContent: mergeSavedQueryContent(content, options),\n existing: options.existing,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n\nexport async function resolveAndUpdateLink(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n title?: string\n url?: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n if (\n options.title === undefined &&\n options.url === undefined &&\n options.description === undefined &&\n options.userFeedback === undefined &&\n options.topics === undefined\n ) {\n throw new ValidationError('Provide at least one field to update.')\n }\n if (options.title === undefined && options.url === undefined) {\n return items.update(uid, {\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n }\n const content = await resolveExistingContent(items, uid, 'link', options.existing)\n return updateWithMergedContent(items, uid, {\n contextType: 'link',\n mergedContent: mergeLinkContent(content, { title: options.title, url: options.url }),\n existing: options.existing,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type {\n Dashboard,\n DashboardDraftSnapshot,\n DashboardVersion,\n} from '../../../../types/context-dashboards.js'\n\n/** Generated base for the management `context.dashboards` resource. */\nexport class ContextDashboardsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * Delete a dashboard.\n *\n * Removes the dashboard from every listing and deletes its alert workflows. It cannot be restored\n * through the API.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.delete('DASHBOARD_ID')\n * ```\n */\n async delete(dashboardId: string): Promise<void> {\n validateId(dashboardId, 'dashboardId')\n await invokeWithRetry(this.config, this.http, 'DashboardsController_delete', {\n pathParams: { dashboardId },\n })\n }\n\n /**\n * List dashboard draft snapshots.\n *\n * Returns ids and timestamps of the most recent draft snapshots. Editors only.\n *\n * **Requires:** `context:read`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')\n * snapshots.map((snapshot) => snapshot.uid)\n * ```\n */\n async listDraftSnapshots(dashboardId: string): Promise<DashboardDraftSnapshot[]> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_listDraftSnapshots', {\n pathParams: { dashboardId },\n })\n return asRecord(data).snapshots as DashboardDraftSnapshot[]\n }\n\n /**\n * Cancel an ownership transfer.\n *\n * Owner only. Clears the pending transfer and returns the dashboard.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')\n * ```\n */\n async cancelOwnershipTransfer(dashboardId: string): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_cancelOwnership', {\n pathParams: { dashboardId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n\n /**\n * Accept an ownership transfer.\n *\n * Recipient only. Makes you the owner and clears the pending transfer.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')\n * ```\n */\n async acceptOwnershipTransfer(dashboardId: string): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_acceptOwnership', {\n pathParams: { dashboardId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n\n /**\n * List dashboard versions.\n *\n * Returns the published versions, newest first, each with its full definition. Draft snapshots\n * are not included. The response is not paginated and can be large.\n *\n * **Requires:** `context:read`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * const versions = await mgmt.context.dashboards.listVersions('DASHBOARD_ID')\n * versions.map((version) => [version.uid, version.versionNumber])\n * ```\n */\n async listVersions(dashboardId: string): Promise<DashboardVersion[]> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_listVersions', {\n pathParams: { dashboardId },\n })\n return asRecord(data).versions as DashboardVersion[]\n }\n\n /**\n * Get a dashboard version.\n *\n * Returns the dashboard as it was in the given version. For a draft snapshot (editors only) the\n * view is reported as active and selectedVersion.versionNumber is null.\n *\n * **Requires:** `context:read`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n * @param versionId - Version id, or a draft snapshot id for editors.\n *\n * @example\n * ```ts\n * const old = await mgmt.context.dashboards.getVersion('DASHBOARD_ID', 'VERSION_ID')\n * old.selectedVersion.versionNumber\n * ```\n */\n async getVersion(\n dashboardId: string,\n versionId: string,\n ): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n validateId(versionId, 'versionId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_getVersion', {\n pathParams: { dashboardId, versionId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n\n /**\n * Restore a dashboard version.\n *\n * Replaces the current draft with the content of the given version. The outgoing draft is kept as\n * a draft snapshot. Returns the draft view.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n * @param versionId - Version id, or a draft snapshot id for editors.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.restoreVersion('DASHBOARD_ID', 'VERSION_ID')\n * ```\n */\n async restoreVersion(\n dashboardId: string,\n versionId: string,\n ): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n validateId(versionId, 'versionId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_restore', {\n pathParams: { dashboardId, versionId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../../_config.js'\nimport type { HttpClient } from '../../../../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../../../../_request.js'\nimport { validateId } from '../../../../../_validation.js'\nimport type {\n DashboardElementResult,\n DashboardElementsList,\n} from '../../../../../types/context-dashboards.js'\n\n/** Generated base for the management `context.dashboards.elements` resource. */\nexport class ContextDashboardsElementsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly dashboardId: number | string,\n ) {}\n\n /**\n * List dashboard elements.\n *\n * Lists every tile and filter on the dashboard draft with id, kind, title and layout. Filters\n * also carry sqlReferences, the exact templates tile SQL must use to reference them. Returns the\n * current draftRevision.\n *\n * **Requires:** `context:read`\n *\n * @example\n * ```ts\n * const listed = await mgmt.context.dashboards.elements('DASHBOARD_ID').list()\n * listed.elements.map((element) => element.id)\n * ```\n */\n async list(): Promise<DashboardElementsList> {\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_listElements', {\n pathParams: { dashboardId: this.dashboardId },\n })\n return asRecord(data) as unknown as DashboardElementsList\n }\n\n /**\n * Get a dashboard element.\n *\n * Returns the full draft configuration of one dashboard element, including SQL, chart settings\n * and filter options, with the current draftRevision.\n *\n * **Requires:** `context:read`\n *\n * @param elementId - The dashboard element id to read.\n *\n * @example\n * ```ts\n * const result = await mgmt.context.dashboards.elements('DASHBOARD_ID').get('ELEMENT_ID')\n * result.element.title\n * ```\n */\n async get(elementId: string): Promise<DashboardElementResult> {\n validateId(elementId, 'elementId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_getElement', {\n pathParams: { dashboardId: this.dashboardId, elementId },\n })\n return asRecord(data) as unknown as DashboardElementResult\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport { ContextDashboardsResourceBase } from '../../_generated/resources/management/context/dashboards.js'\nimport { ContextDashboardsElementsResourceBase } from '../../_generated/resources/management/context/dashboards/elements.js'\nimport type { HttpClient } from '../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type {\n CreateDashboardElementInput,\n CreateDashboardInput,\n Dashboard,\n DashboardElementResult,\n DashboardPublishResult,\n DashboardView,\n PublishDashboardInput,\n TransferDashboardOwnershipInput,\n UpdateDashboardAccessInput,\n UpdateDashboardDraftInput,\n UpdateDashboardElementInput,\n UpdateDashboardLayoutInput,\n} from '../../types/context-dashboards.js'\n\n/**\n * Tiles and filters on one dashboard draft.\n *\n * Call path: `mgmt.context.dashboards.elements(dashboardId)`.\n *\n * Every change takes the `draftRevision` it is based on as `expectedRevision`;\n * a stale value is rejected with a `ConflictError`.\n */\nexport class ManagementDashboardElementsResource extends ContextDashboardsElementsResourceBase {\n /** @internal */\n constructor(\n http: HttpClient,\n config: ModusConfig,\n dashboardId: string,\n ) {\n super(http, config, dashboardId)\n }\n\n /**\n * Add a blank tile or filter to the dashboard draft.\n *\n * Modus assigns the new element's id; configure it afterwards with `update()`.\n *\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.kind - `chart`, `kpi`, `table`, `markdown` or `filter`.\n * @param input.title - Title shown on the element.\n * @param input.layout - Grid position with `x` (0-11), `y`, `w` (1-12) and `h`.\n * @returns The created element and the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`; list the\n * elements again and retry with the new revision.\n * @example\n * ```ts\n * const created = await mgmt.context.dashboards.elements('DASHBOARD_ID').create({\n * expectedRevision: 3,\n * kind: 'chart',\n * title: 'Sales by region',\n * layout: { x: 0, y: 4, w: 6, h: 4 },\n * })\n * ```\n */\n async create(input: CreateDashboardElementInput): Promise<DashboardElementResult> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_createElement', {\n pathParams: { dashboardId: this.dashboardId },\n jsonBody: {\n expectedRevision: input.expectedRevision,\n kind: input.kind,\n title: input.title,\n layout: input.layout,\n },\n }),\n ) as unknown as DashboardElementResult\n }\n\n /**\n * Change settings of one tile or filter on the dashboard draft.\n *\n * @param elementId - Id of the tile or filter to change.\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.patch - The settings to change, for example `{ title: 'Sales' }`\n * or `{ defaultValue: null }`. `null` clears a setting that supports clearing.\n * @returns The whole dashboard after the change, including the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`.\n * @throws NotFoundError - The dashboard or the element does not exist, or you cannot\n * edit the dashboard.\n * @example\n * ```ts\n * const dashboard = await mgmt.context.dashboards\n * .elements('DASHBOARD_ID')\n * .update('ELEMENT_ID', { expectedRevision: 3, patch: { title: 'Revenue' } })\n * ```\n */\n async update(elementId: string, input: UpdateDashboardElementInput): Promise<Dashboard> {\n validateId(elementId, 'elementId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateElement', {\n pathParams: { dashboardId: this.dashboardId, elementId },\n jsonBody: { expectedRevision: input.expectedRevision, patch: input.patch },\n }),\n ) as unknown as Dashboard\n }\n}\n\n/**\n * Dashboards in the Modus knowledge base.\n *\n * Call path: `mgmt.context.dashboards` after `new ModusManagement(...)`.\n *\n * - `list()`, `get()`, `create()`, `updateDraft()`, `publish()`, `delete()` — dashboards.\n * - `listVersions()`, `getVersion()`, `restoreVersion()`, `listDraftSnapshots()` — history.\n * - `updateAccess()` — who can open and edit a dashboard.\n * - `requestOwnershipTransfer()`, `acceptOwnershipTransfer()`, `cancelOwnershipTransfer()`.\n * - `elements(dashboardId)` — list, get, create and update tiles and filters.\n * - `updateLayout(dashboardId, input)` — move or resize several elements at once.\n */\nexport class ManagementDashboardsResource extends ContextDashboardsResourceBase {\n /** @internal */\n constructor(\n http: HttpClient,\n config: ModusConfig,\n ) {\n super(http, config)\n }\n\n /**\n * List dashboards with their full definitions.\n *\n * @param options.view - `active` (default) lists published dashboards you can open;\n * `draft` lists the drafts of dashboards you can edit.\n * @returns Every matching dashboard. The list is not paginated.\n * @example\n * ```ts\n * const drafts = await mgmt.context.dashboards.list({ view: 'draft' })\n * drafts.map((dashboard) => [dashboard.id, dashboard.draftRevision])\n * ```\n */\n async list(options: { view?: DashboardView } = {}): Promise<Dashboard[]> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_list', {\n query: { view: options.view },\n }),\n )\n return data.dashboards as Dashboard[]\n }\n\n /**\n * Get one dashboard with its full definition.\n *\n * @param dashboardId - Id of the dashboard.\n * @param options.view - `active` (default) returns the published version; `draft`\n * returns the working draft and requires edit access.\n * @returns The dashboard, including `draftRevision` for the next change.\n * @throws NotFoundError - The dashboard does not exist or you cannot open it.\n * @example\n * ```ts\n * const draft = await mgmt.context.dashboards.get('DASHBOARD_ID', { view: 'draft' })\n * draft.draftRevision\n * ```\n */\n async get(dashboardId: string, options: { view?: DashboardView } = {}): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_get', {\n pathParams: { dashboardId },\n query: { view: options.view },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Create a dashboard draft.\n *\n * The new dashboard is not visible to others until you `publish()` it.\n *\n * @param input.title - Dashboard title.\n * @param input.definition - Tiles, filters and layout, for example\n * `{ tiles: [], filters: [] }`. Element ids must be unique.\n * @param input.description - Optional dashboard description.\n * @param input.access - Optional `visibility`, `groupPermissions` and `sharedWith`.\n * Defaults to private.\n * @returns The created dashboard in its draft view.\n * @throws ModusError - The definition or access settings are invalid.\n * @example\n * ```ts\n * const dashboard = await mgmt.context.dashboards.create({\n * title: 'Revenue',\n * definition: { tiles: [], filters: [] },\n * })\n * dashboard.id\n * ```\n */\n async create(input: CreateDashboardInput): Promise<Dashboard> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_create', {\n jsonBody: {\n title: input.title,\n description: input.description,\n definition: input.definition,\n access: input.access,\n },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Replace the whole draft definition, and optionally the title and description.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.definition - The complete new definition. Tiles and filters left\n * out are removed.\n * @param input.title - New title; unchanged when omitted.\n * @param input.description - New description; unchanged when omitted.\n * @returns The dashboard draft after the change, including the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`; get the draft\n * again and retry with the new revision.\n * @throws NotFoundError - The dashboard does not exist or you cannot edit it.\n * @example\n * ```ts\n * const draft = await mgmt.context.dashboards.get('DASHBOARD_ID', { view: 'draft' })\n * await mgmt.context.dashboards.updateDraft('DASHBOARD_ID', {\n * expectedRevision: draft.draftRevision,\n * definition: draft.definition,\n * title: 'Revenue',\n * })\n * ```\n */\n async updateDraft(dashboardId: string, input: UpdateDashboardDraftInput): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateDraft', {\n pathParams: { dashboardId },\n jsonBody: {\n expectedRevision: input.expectedRevision,\n title: input.title,\n description: input.description,\n definition: input.definition,\n },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Publish the draft as a new version that everyone with access sees.\n *\n * Alert workflows defined on the dashboard are updated to match.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.expectedRevision - The `draftRevision` you reviewed and want to publish.\n * @returns The published `dashboard` and the new `version`.\n * @throws ConflictError - The draft changed since `expectedRevision`.\n * @throws NotFoundError - The dashboard does not exist or you cannot edit it.\n * @example\n * ```ts\n * const result = await mgmt.context.dashboards.publish('DASHBOARD_ID', { expectedRevision: 4 })\n * result.version.versionNumber\n * ```\n */\n async publish(dashboardId: string, input: PublishDashboardInput): Promise<DashboardPublishResult> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_publish', {\n pathParams: { dashboardId },\n jsonBody: { expectedRevision: input.expectedRevision },\n }),\n ) as unknown as DashboardPublishResult\n }\n\n /**\n * Replace who can open and edit a dashboard.\n *\n * All three settings are required and replace the current ones.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.visibility - `shared` (the owner plus the groups in\n * `groupPermissions`) or `private` (the owner plus the users in `sharedWith`).\n * @param input.groupPermissions - Group id to `{ use, manage }`. Used only when shared.\n * @param input.sharedWith - Users such as `{ email: 'ana@example.com', permission: 'use' }`.\n * Used only when private.\n * @returns The dashboard with its new access settings.\n * @throws NotFoundError - The dashboard does not exist or you cannot edit it.\n * @throws ModusError - A group, user or permission is invalid.\n * @example\n * ```ts\n * await mgmt.context.dashboards.updateAccess('DASHBOARD_ID', {\n * visibility: 'private',\n * groupPermissions: {},\n * sharedWith: [{ email: 'ana@example.com', permission: 'use' }],\n * })\n * ```\n */\n async updateAccess(dashboardId: string, input: UpdateDashboardAccessInput): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateAccess', {\n pathParams: { dashboardId },\n jsonBody: {\n visibility: input.visibility,\n groupPermissions: input.groupPermissions,\n sharedWith: input.sharedWith,\n },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Ask another member of your organization to take ownership of a dashboard.\n *\n * Only the owner can request a transfer. Ownership moves when the recipient\n * calls `acceptOwnershipTransfer()`.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.newOwnerUserId - User id of the member who should become the owner.\n * @returns The dashboard with `pendingOwnershipTransfer` set.\n * @throws PermissionDeniedError - You are not the owner.\n * @throws NotFoundError - The dashboard does not exist or you cannot open it.\n * @example\n * ```ts\n * await mgmt.context.dashboards.requestOwnershipTransfer('DASHBOARD_ID', {\n * newOwnerUserId: 'USER_ID',\n * })\n * ```\n */\n async requestOwnershipTransfer(\n dashboardId: string,\n input: TransferDashboardOwnershipInput,\n ): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n validateId(input.newOwnerUserId, 'newOwnerUserId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_transferOwnership', {\n pathParams: { dashboardId },\n jsonBody: { newOwnerUserId: input.newOwnerUserId },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Work with the tiles and filters of one dashboard draft.\n *\n * @param dashboardId - Id of the dashboard.\n * @returns A resource bound to that dashboard.\n * @example\n * ```ts\n * await mgmt.context.dashboards.elements('DASHBOARD_ID').list()\n * ```\n */\n elements(dashboardId: string): ManagementDashboardElementsResource {\n validateId(dashboardId, 'dashboardId')\n return new ManagementDashboardElementsResource(this.http, this.config, dashboardId)\n }\n\n /**\n * Move or resize several tiles and filters in one change.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.elements - Every element to place, each with `elementId` and its\n * final `layout`.\n * @returns The whole dashboard after the change, including the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`.\n * @example\n * ```ts\n * await mgmt.context.dashboards.updateLayout('DASHBOARD_ID', {\n * expectedRevision: 3,\n * elements: [{ elementId: 'ELEMENT_ID', layout: { x: 0, y: 0, w: 12, h: 2 } }],\n * })\n * ```\n */\n async updateLayout(dashboardId: string, input: UpdateDashboardLayoutInput): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateLayout', {\n pathParams: { dashboardId },\n jsonBody: { expectedRevision: input.expectedRevision, elements: input.elements },\n }),\n ) as unknown as Dashboard\n }\n}\n","import { readdir, readFile, stat } from 'node:fs/promises'\nimport { dirname, join, relative } from 'node:path'\nimport type { ModusConfig } from '../../_config.js'\nimport { ModusError, ValidationError } from '../../_exceptions.js'\nimport { ContextFilesResourceBase } from '../../_generated/resources/management/context/files.js'\nimport type { HttpClient } from '../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type {\n BulkFinalizeResult,\n BulkUploadFromUrlsResult,\n BulkUploadUrlsResult,\n FileUpload,\n FinalizeInput,\n UploadDirFailure,\n UploadDirResult,\n UploadFileInput,\n UploadFromUrlInput,\n UploadProgressCallback,\n UploadUrlInput,\n UploadUrlSlot,\n WaitUntil,\n} from '../../types/context-files.js'\n\n/** Bulk `createUploadUrls` / `uploadFromUrls` request cap — matches the backend. */\nexport const MAX_BULK_UPLOAD_FILES = 100\n\nconst DEFAULT_PUT_TIMEOUT_MS = 60_000\nconst DEFAULT_POLL_INTERVAL_MS = 500\nconst DEFAULT_UPLOAD_TIMEOUT_MS = 120_000\nconst DEFAULT_CONCURRENCY = 10\n// `pending` is gone from the public enum: an upload has no resource until it\n// is finalized. Kept at rank 0 so an older server still reporting it is\n// ordered below `processing` rather than treated as unknown.\nconst STATUS_ORDER: Record<string, number> = { pending: 0, processing: 1, ready: 2 }\nconst WAIT_UNTIL_VALUES = new Set<WaitUntil>(['processing', 'ready'])\n\n/**\n * The server owns the extension→MIME table (`EXTENSION_MIME_MAP` in\n * `@modus/file-uploads`) and resolves it whenever a client sends\n * `application/octet-stream`. Sending that instead of guessing locally keeps\n * one source of truth: a client-side table inevitably drifts from the server's\n * allow-list, and a guess the server rejects fails the upload for no reason.\n */\nconst DEFER_CONTENT_TYPE_TO_SERVER = 'application/octet-stream'\n\n/** A missing path (or one under a regular file, ENOTDIR) is bad caller input, so it throws ValidationError like a wrong file type does. */\nasync function statInput(path: string) {\n try {\n return await stat(path)\n } catch (error) {\n const code = (error as { code?: unknown }).code\n if (code === 'ENOENT' || code === 'ENOTDIR') throw new ValidationError(`No such file or directory: ${path}`)\n throw error\n }\n}\n\nfunction validateWaitUntil(waitUntil: string): asserts waitUntil is WaitUntil {\n if (!WAIT_UNTIL_VALUES.has(waitUntil as WaitUntil)) {\n throw new ValidationError(`waitUntil must be one of ${[...WAIT_UNTIL_VALUES].join(', ')}, got ${waitUntil}`)\n }\n}\n\nfunction validateBulkSize(count: number, name: string): void {\n if (count === 0) throw new ValidationError(`${name} must not be empty`)\n if (count > MAX_BULK_UPLOAD_FILES) {\n throw new ValidationError(`${name} must have at most ${MAX_BULK_UPLOAD_FILES} entries, got ${count}`)\n }\n}\n\nfunction statusSatisfies(status: string, waitUntil: WaitUntil): boolean {\n if (status === 'failed') return true\n return (STATUS_ORDER[status] ?? 0) >= STATUS_ORDER[waitUntil]\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\nfunction chunked<T>(items: readonly T[], size: number): T[][] {\n const out: T[][] = []\n for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size))\n return out\n}\n\n/** Join an optional destination prefix onto a walk-relative folder label. Empty prefix is a no-op. */\nfunction joinDestination(prefix: string | undefined, relative: string | undefined): string | undefined {\n const head = prefix === undefined || prefix.length === 0 ? undefined : prefix\n const tail =\n relative === undefined || relative.length === 0\n ? undefined\n : relative\n if (head !== undefined && tail !== undefined) return `${head}/${tail}`\n return head ?? tail\n}\n\nexport type BatchUploadOptions = {\n concurrency?: number\n waitUntil?: WaitUntil\n onProgress?: UploadProgressCallback\n folderPath?: string\n}\n\n/** Bounded-concurrency map, preserving input order — the async twin of a thread pool. */\nasync function mapWithConcurrency<T, R>(\n items: readonly T[],\n concurrency: number,\n worker: (item: T) => Promise<R>,\n onItemDone?: (result: R) => void,\n): Promise<R[]> {\n const results: R[] = new Array(items.length)\n let cursor = 0\n async function run(): Promise<void> {\n for (;;) {\n const index = cursor++\n if (index >= items.length) return\n const result = await worker(items[index] as T)\n results[index] = result\n onItemDone?.(result)\n }\n }\n await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, run))\n return results\n}\n\nasync function walkFiles(root: string, recursive: boolean): Promise<string[]> {\n const out: string[] = []\n async function walk(dir: string): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true })\n entries.sort((a, b) => a.name.localeCompare(b.name))\n for (const entry of entries) {\n if (entry.name.startsWith('.') || entry.isSymbolicLink()) continue\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n if (recursive) await walk(full)\n } else if (entry.isFile()) {\n out.push(full)\n }\n }\n }\n await walk(root)\n return out\n}\n\n// Servers released before `headers` existed omit it; their PUT needs only Content-Type.\ntype PutSlot = Pick<UploadUrlSlot, 'uploadUrl' | 'contentType'> & { headers?: Record<string, string> }\n\nasync function putBytes(fetchImpl: typeof fetch, slot: PutSlot, data: Uint8Array, timeoutMs: number): Promise<void> {\n const response = await fetchImpl(slot.uploadUrl, {\n method: 'PUT',\n body: data,\n headers: { 'Content-Type': slot.contentType, ...slot.headers },\n signal: AbortSignal.timeout(timeoutMs),\n })\n if (!response.ok) {\n const text = await response.text().catch(() => '')\n throw new ModusError(`Upload PUT to presigned URL failed with HTTP ${response.status}.`, {\n statusCode: response.status,\n body: text ? text.slice(0, 500) : undefined,\n })\n }\n}\n\nfunction createSlotsPayload(files: readonly UploadUrlInput[]): Record<string, unknown> {\n return {\n files: files.map((f) => ({ fileName: f.fileName, contentType: f.contentType, fileSize: f.fileSize })),\n }\n}\n\nfunction uploadFromUrlsPayload(urls: readonly UploadFromUrlInput[]): Record<string, unknown> {\n return {\n urls: urls.map((u) => ({\n url: u.url,\n ...(u.fileName !== undefined ? { fileName: u.fileName } : {}),\n ...(u.folderPath !== undefined ? { folderPath: u.folderPath } : {}),\n })),\n }\n}\n\ntype UploadPath = UploadFileInput\ntype SlotAssignment = UploadPath & { slot: UploadUrlSlot }\n\nfunction assignSlots(\n batch: readonly UploadPath[],\n result: BulkUploadUrlsResult,\n failed: UploadDirFailure[],\n): SlotAssignment[] {\n const failedIndices = new Set(result.failed.map((f) => f.index))\n for (const f of result.failed) {\n failed.push({ path: batch[f.index]?.path ?? '', error: f.error })\n }\n const remaining = batch.filter((_, i) => !failedIndices.has(i))\n const uploaded = result.uploaded\n if (uploaded.length < remaining.length) {\n for (const file of remaining.slice(uploaded.length)) {\n failed.push({ path: file.path, error: 'Server returned fewer upload slots than requested files.' })\n }\n }\n const paired = Math.min(remaining.length, uploaded.length)\n const assignments: SlotAssignment[] = []\n for (let i = 0; i < paired; i++) {\n assignments.push({ ...(remaining[i] as UploadPath), slot: uploaded[i] as UploadUrlSlot })\n }\n return assignments\n}\n\n/**\n * Durable file uploads for `ModusManagement`.\n *\n * Call path: `mgmt.context.files` after `new ModusManagement(...)`.\n *\n * - `upload(path)` / `uploadDir(dirPath)` — presign + PUT + poll convenience helpers.\n * - `createUploadUrl(s)`, `uploadFromUrl(s)`, `get`, `list` — raw operations.\n * Hierarchy browsing is available through `mgmt.context.items.list`.\n */\nexport class ManagementContextFilesResource extends ContextFilesResourceBase {\n /** @internal */\n constructor(\n http: HttpClient,\n config: ModusConfig,\n ) {\n super(http, config)\n }\n\n /**\n * Get a presigned S3 PUT URL for one file.\n *\n * @param input.fileName - Original file name — used to build the S3 object key.\n * @param input.contentType - MIME type. Allowed categories: PDF, images, text,\n * Office/OpenDocument documents, audio, and video.\n * @param input.fileSize - File size in bytes. Rejected above 50MB.\n * @returns Presigned upload slot. PUT the raw bytes to `uploadUrl` within 15\n * minutes, sending `headers` unchanged, then call `finalize(slot.uploadId, slot.fileName)`. Pass the\n * slot's own `fileName` rather than your local basename — the server may\n * sanitize the requested name when it mints the key, and finalization\n * re-derives the key from `uploadId` and `fileName`.\n */\n async createUploadUrl(input: UploadUrlInput): Promise<UploadUrlSlot> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadUrl', {\n jsonBody: { fileName: input.fileName, contentType: input.contentType, fileSize: input.fileSize },\n }),\n ) as unknown as UploadUrlSlot\n }\n\n /**\n * Get presigned S3 PUT URLs for up to 100 files in one call.\n *\n * @param files - Files to create upload slots for (max 100).\n * @returns Slots for every file that passed validation, plus per-index\n * failures (bad MIME type, oversize) for the rest — never a partial 4xx.\n */\n async createUploadUrls(files: readonly UploadUrlInput[]): Promise<BulkUploadUrlsResult> {\n validateBulkSize(files.length, 'files')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadUrls', {\n jsonBody: createSlotsPayload(files),\n }),\n ) as unknown as BulkUploadUrlsResult\n }\n\n /**\n * Fetch one file from a URL and land it as durable context.\n *\n * @param url - Source URL to fetch (SSRF-guarded, 50MB cap, same MIME\n * allow-list as `createUploadUrl`).\n * @param options.fileName - Override file name. Inferred from the URL path when omitted.\n * @param options.folderPath - Root-relative folder to upload under.\n * @returns File upload resource with status `processing` — parsing continues async.\n */\n async uploadFromUrl(url: string, options: { fileName?: string; folderPath?: string } = {}): Promise<FileUpload> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadFromUrl', {\n jsonBody: {\n url,\n ...(options.fileName !== undefined ? { fileName: options.fileName } : {}),\n ...(options.folderPath !== undefined ? { folderPath: options.folderPath } : {}),\n },\n }),\n ) as unknown as FileUpload\n }\n\n /**\n * Fetch up to 100 files from URLs in one call.\n *\n * @param urls - URLs to fetch and upload (max 100).\n * @returns File upload resources for every URL that landed, plus per-index\n * failures for the rest — never a partial 4xx.\n */\n async uploadFromUrls(urls: readonly UploadFromUrlInput[]): Promise<BulkUploadFromUrlsResult> {\n validateBulkSize(urls.length, 'urls')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadFromUrls', {\n jsonBody: uploadFromUrlsPayload(urls),\n }),\n ) as unknown as BulkUploadFromUrlsResult\n }\n\n /**\n * Turn a file already PUT to a presigned URL into durable context.\n *\n * Call this once the PUT completes. The server locates the object from\n * `uploadId` + `fileName` and validates the bytes that actually arrived.\n * Safe to retry — a second call returns the same resource.\n *\n * @param uploadId - Upload id returned by `createUploadUrl`.\n * @param fileName - File name returned alongside it.\n * @returns The file upload resource, status `\"processing\"`.\n */\n async finalize(uploadId: string, fileName: string, options: { folderPath?: string } = {}): Promise<FileUpload> {\n validateId(uploadId, 'uploadId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_finalize', {\n pathParams: { uploadId },\n jsonBody: { fileName, ...(options.folderPath !== undefined ? { folderPath: options.folderPath } : {}) },\n }),\n ) as unknown as FileUpload\n }\n\n /**\n * Finalize up to 100 uploads in one call.\n *\n * What makes directory upload cheap: 2000 files cost 20 requests here rather\n * than 2000.\n *\n * @param uploads - Uploads to finalize (max 100).\n * @returns Resources for every upload that finalized, plus per-index\n * failures for the rest — never a partial 4xx.\n */\n async finalizeMany(uploads: readonly FinalizeInput[]): Promise<BulkFinalizeResult> {\n validateBulkSize(uploads.length, 'uploads')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_finalizeMany', {\n jsonBody: {\n uploads: uploads.map((u) => ({\n uploadId: u.uploadId,\n fileName: u.fileName,\n ...(u.folderPath !== undefined ? { folderPath: u.folderPath } : {}),\n })),\n },\n }),\n ) as unknown as BulkFinalizeResult\n }\n\n /**\n * Upload an explicit list of local files.\n *\n * Same machinery as `uploadDir`, without the directory walk — use it when\n * the caller already knows which files to send.\n *\n * @param paths - Paths to local files.\n * @param options.concurrency - Max concurrent PUTs (default 10).\n * @param options.waitUntil - `\"processing\"` (default) or `\"ready\"`.\n * @param options.onProgress - Optional progress callback after each file.\n * @param options.folderPath - Root-relative folder to upload under. Nested\n * files keep their existing relative folder labels under this prefix.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const result = await mgmt.context.files.uploadFiles(\n * ['./q3.pdf', './notes.md'],\n * { folderPath: 'reports/2026' },\n * )\n * ```\n */\n async uploadFiles(\n paths: readonly (string | UploadFileInput)[],\n options: BatchUploadOptions = {},\n ): Promise<UploadDirResult> {\n return this.uploadPaths(paths.map((input) => typeof input === 'string' ? { path: input } : input), options)\n }\n\n /**\n * Upload a local file and wait for it to reach `\"processing\"` or `\"ready\"`.\n *\n * Gets a presigned URL, PUTs the file bytes, then polls `get()`\n * until the upload leaves `\"pending\"` (or reaches `\"ready\"`/`\"failed\"`).\n *\n * @param path - Path to a local file.\n * @param options.waitUntil - `\"processing\"` (parsing started, default) or\n * `\"ready\"` (parsing finished).\n * @param options.pollIntervalMs - Milliseconds between status polls.\n * @param options.timeoutMs - Max milliseconds to wait before raising.\n * @param options.folderPath - Root-relative folder to upload under. Example:\n * `{ folderPath: 'reports/2026' }` places `./report.pdf` at `reports/2026`.\n * @returns The file upload resource once it reaches `waitUntil` (or `\"failed\"`).\n * @throws {ModusError} If the PUT fails, or polling times out.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const file = await mgmt.context.files.upload('./report.pdf', { folderPath: 'reports/2026' })\n * ```\n */\n async upload(\n path: string,\n options: {\n waitUntil?: WaitUntil\n pollIntervalMs?: number\n timeoutMs?: number\n folderPath?: string\n } = {},\n ): Promise<FileUpload> {\n const waitUntil = options.waitUntil ?? 'processing'\n validateWaitUntil(waitUntil)\n const fileStat = await statInput(path)\n if (!fileStat.isFile()) throw new ValidationError(`Not a file: ${path}`)\n const fileName = path.split(/[/\\\\]/).pop() as string\n const slot = await this.createUploadUrl({\n fileName,\n contentType: DEFER_CONTENT_TYPE_TO_SERVER,\n fileSize: fileStat.size,\n })\n const data = await readFile(path)\n await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS)\n // Finalize returns the resource already at `processing`, so it replaces the\n // first poll rather than adding a round trip. Only `waitUntil: 'ready'`\n // needs to keep polling afterwards.\n const finalized = await this.finalize(slot.uploadId, slot.fileName, {\n ...(options.folderPath !== undefined ? { folderPath: options.folderPath } : {}),\n })\n if (statusSatisfies(finalized.status, waitUntil)) return finalized\n return this.pollUntil(\n slot.uploadId,\n waitUntil,\n options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS,\n options.timeoutMs ?? DEFAULT_UPLOAD_TIMEOUT_MS,\n )\n }\n\n private async pollUntil(\n uploadId: string,\n waitUntil: WaitUntil,\n pollIntervalMs: number,\n timeoutMs: number,\n ): Promise<FileUpload> {\n const deadline = Date.now() + timeoutMs\n for (;;) {\n const item = await this.get(uploadId)\n if (statusSatisfies(item.status, waitUntil)) return item\n if (Date.now() >= deadline) {\n throw new ModusError(\n `Timed out after ${timeoutMs}ms waiting for upload ${JSON.stringify(uploadId)} to reach ` +\n `status ${JSON.stringify(waitUntil)}; last status was ${JSON.stringify(item.status)}.`,\n )\n }\n await sleep(pollIntervalMs)\n }\n }\n\n /**\n * Upload every file in a local directory.\n *\n * Walks `path` (skipping hidden files/directories and symlinks), pages\n * through `createUploadUrls()` in batches of up to 100, then PUTs and polls\n * each file with up to `concurrency` in flight at once. A failure on one\n * file does not stop the others — check `result.failed`.\n *\n * @param path - Path to a local directory.\n * @param options.recursive - Recurse into subdirectories (default `true`).\n * @param options.concurrency - Max concurrent PUT+poll operations (default 10).\n * @param options.waitUntil - `\"processing\"` (default) or `\"ready\"` — same as `upload()`.\n * @param options.onProgress - Optional progress callback after each file.\n * @param options.folderPath - Root-relative folder to upload under. Nested\n * files keep their path relative to `path` under this prefix. Example:\n * `uploadDir('./docs', { folderPath: 'reports' })` places `./docs/a.txt` at\n * `reports` and `./docs/nested/b.txt` at `reports/nested`.\n * @returns `UploadDirResult` with every successful `FileUpload` and every\n * per-file failure (slot creation or PUT/poll), each tagged with its local path.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const result = await mgmt.context.files.uploadDir('./docs', { folderPath: 'reports' })\n * ```\n */\n async uploadDir(\n path: string,\n options: {\n recursive?: boolean\n concurrency?: number\n waitUntil?: WaitUntil\n onProgress?: UploadProgressCallback\n folderPath?: string\n } = {},\n ): Promise<UploadDirResult> {\n const waitUntil = options.waitUntil ?? 'processing'\n validateWaitUntil(waitUntil)\n const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY\n if (concurrency < 1) throw new ValidationError(`concurrency must be >= 1, got ${concurrency}`)\n const dirStat = await statInput(path)\n if (!dirStat.isDirectory()) throw new ValidationError(`Not a directory: ${path}`)\n\n const files = await walkFiles(path, options.recursive ?? true)\n return this.uploadPaths(files.map((file) => {\n const folderPath = relative(path, dirname(file)).replace(/\\\\/g, '/')\n return { path: file, ...(folderPath.length > 0 ? { folderPath } : {}) }\n }), options)\n }\n\n /** Shared body of `uploadFiles` and `uploadDir`: presign in batches of 100,\n * PUT with bounded concurrency, then bulk-finalize the batch. */\n private async uploadPaths(\n files: readonly UploadPath[],\n options: BatchUploadOptions,\n ): Promise<UploadDirResult> {\n const waitUntil = options.waitUntil ?? 'processing'\n validateWaitUntil(waitUntil)\n const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY\n if (concurrency < 1) throw new ValidationError(`concurrency must be >= 1, got ${concurrency}`)\n\n const prefixed = files.map((file) => {\n const folderPath = joinDestination(options.folderPath, file.folderPath)\n return { path: file.path, ...(folderPath !== undefined ? { folderPath } : {}) }\n })\n\n const uploaded: FileUpload[] = []\n const failed: UploadDirFailure[] = []\n const total = files.length\n let completed = 0\n const emit = () => {\n completed += 1\n options.onProgress?.({\n completed,\n total,\n succeeded: uploaded.length,\n failed: failed.length,\n })\n }\n\n for (const batch of chunked(prefixed, MAX_BULK_UPLOAD_FILES)) {\n const failedBefore = failed.length\n const slots = await this.createSlots(batch, failed)\n // createSlots can report several failures from one synchronous call, so tick\n // `failed` up one at a time here — reusing `emit()` would report the final\n // `failed.length` on every tick and break the completed = succeeded + failed\n // invariant for all but the last of them.\n for (let reported = failedBefore + 1; reported <= failed.length; reported += 1) {\n completed += 1\n options.onProgress?.({ completed, total, succeeded: uploaded.length, failed: reported })\n }\n await this.uploadBatch(slots, waitUntil, concurrency, (result) => {\n if ('error' in result) failed.push(result)\n else uploaded.push(result)\n emit()\n })\n }\n return { uploaded, failed }\n }\n\n private async createSlots(batch: readonly UploadPath[], failed: UploadDirFailure[]): Promise<SlotAssignment[]> {\n const readable: UploadPath[] = []\n const inputs: UploadUrlInput[] = []\n for (const file of batch) {\n try {\n const fileStat = await stat(file.path)\n const fileName = file.path.split(/[/\\\\]/).pop() as string\n inputs.push({ fileName, contentType: DEFER_CONTENT_TYPE_TO_SERVER, fileSize: fileStat.size })\n readable.push(file)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n failed.push({ path: file.path, error: message })\n }\n }\n if (inputs.length === 0) return []\n const result = await this.createUploadUrls(inputs)\n return assignSlots(readable, result, failed)\n }\n\n private async uploadBatch(\n slots: readonly SlotAssignment[],\n waitUntil: WaitUntil,\n concurrency: number,\n onOutcome?: (result: FileUpload | UploadDirFailure) => void,\n ): Promise<(FileUpload | UploadDirFailure)[]> {\n if (slots.length === 0) return []\n const out: (FileUpload | UploadDirFailure)[] = []\n\n // PUT everything first, collecting the ones whose bytes landed.\n type PutOutcome = { landed: SlotAssignment } | { failure: UploadDirFailure }\n const put = await mapWithConcurrency<SlotAssignment, PutOutcome>(\n slots,\n concurrency,\n async ({ path, folderPath, slot }) => {\n try {\n const data = await readFile(path)\n await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS)\n return { landed: { path, ...(folderPath !== undefined ? { folderPath } : {}), slot } }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n return { failure: { path, error: message } }\n }\n },\n (outcome) => {\n // Emit PUT failures as each concurrent worker finishes — do not wait for\n // the rest of the batch / finalize before progress moves.\n if ('failure' in outcome) {\n out.push(outcome.failure)\n onOutcome?.(outcome.failure)\n }\n },\n )\n const landed: SlotAssignment[] = []\n for (const entry of put) {\n if ('failure' in entry) {\n // already recorded + emitted in onItemDone\n continue\n }\n landed.push(entry.landed)\n }\n if (landed.length === 0) return out\n\n // One bulk finalize for the whole batch — the reason a 2000-file directory\n // costs 20 requests here instead of 2000.\n const result = await this.finalizeMany(\n landed.map(({ slot, folderPath }) => ({\n uploadId: slot.uploadId,\n fileName: slot.fileName,\n ...(folderPath !== undefined ? { folderPath } : {}),\n })),\n )\n const failedIndices = new Set(result.failed.map((f) => f.index))\n for (const f of result.failed) {\n const failure: UploadDirFailure = { path: landed[f.index]?.path ?? '', error: f.error }\n out.push(failure)\n onOutcome?.(failure)\n }\n const finalized = result.finalized\n const remaining = landed.filter((_, i) => !failedIndices.has(i))\n\n if (waitUntil !== 'ready') {\n for (const item of finalized) {\n out.push(item)\n onOutcome?.(item)\n }\n return out\n }\n\n // Only `ready` needs polling; `processing` is already satisfied by the\n // finalize response.\n await mapWithConcurrency(\n remaining,\n concurrency,\n async ({ path, slot }) => {\n try {\n return await this.pollUntil(slot.uploadId, waitUntil, DEFAULT_POLL_INTERVAL_MS, DEFAULT_UPLOAD_TIMEOUT_MS)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n return { path, error: message } satisfies UploadDirFailure\n }\n },\n (item) => {\n out.push(item)\n onOutcome?.(item)\n },\n )\n return out\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../../../_request.js'\nimport { validateId, validatePageSize } from '../../../../_validation.js'\nimport type { FileUpload } from '../../../../types/context-files.js'\n\n/** Generated base for the management `context.files` resource. */\nexport class ContextFilesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List file uploads.\n *\n * Returns a page of durable landed file uploads. Uploads that have not landed yet are visible via\n * `GET /context/files/{uploadId}`, not this list.\n *\n * **Requires:** `context:read`\n *\n * @param options.pageSize - Items per page. Defaults to 50.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @returns A page of files.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<FileUpload>> {\n const pageSize = options.pageSize ?? 50\n validatePageSize(pageSize, 200)\n return this.listPage(pageSize, options.pageToken)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<FileUpload>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_list', {\n query: aipListParams(pageSize, pageToken) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'files',\n (raw) => raw as FileUpload,\n (token) => this.listPage(pageSize, token),\n )\n }\n\n /**\n * Get a file upload.\n *\n * Returns status + metadata for one upload. Prefers the durable landed context item; falls back\n * to in-flight upload status while the object has not landed yet. 404 if neither exists.\n *\n * **Requires:** `context:read`\n *\n * @param uploadId - Upload id returned by `createUploadUrl` / `createUploadUrls`.\n */\n async get(uploadId: string): Promise<FileUpload> {\n validateId(uploadId, 'uploadId')\n const data = await invokeWithRetry(this.config, this.http, 'ContextFilesController_get', {\n pathParams: { uploadId },\n })\n return asRecord(data) as unknown as FileUpload\n }\n}\n","import type { OperationId } from '../../_generated/operations.js'\nimport type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { aipListParams, buildAipPage, type Page } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { validatePageSize } from '../../_validation.js'\nimport type {\n ContextItem,\n ContextItemAccessUpdate,\n ContextItemDeletion,\n ContextItemMove,\n UpdateContextItemAccessInput,\n} from '../../types/context.js'\nimport type { UserFeedback } from './_content-merge.js'\n\nfunction contextListParams(\n pageSize: number,\n pageToken: string | undefined,\n filters: ListContextItemsFilters = {},\n): Record<string, string | number | boolean | readonly string[] | undefined | null> {\n const extra: Record<string, string | readonly string[]> = {}\n if (filters.contextType !== undefined) extra.contextTypes = [filters.contextType]\n if (filters.parentUids !== undefined) {\n extra.parentUids = filters.parentUids.length === 0 ? '' : [...filters.parentUids]\n }\n if (filters.ancestorUids !== undefined) {\n extra.ancestorUids = filters.ancestorUids.length === 0 ? '' : [...filters.ancestorUids]\n }\n if (filters.connectionIds !== undefined) {\n extra.connectionIds = filters.connectionIds.length === 0 ? '' : [...filters.connectionIds]\n }\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | readonly string[] | undefined | null\n >\n}\n\ntype ListContextItemsFilters = {\n contextType?: string\n parentUids?: readonly string[]\n ancestorUids?: readonly string[]\n connectionIds?: readonly string[]\n}\n\nfunction parseContextItem(raw: unknown): ContextItem {\n return raw as ContextItem\n}\n\nexport class ManagementContextItemsResource {\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List context items in the knowledge base.\n *\n * @param options.pageSize - Items per page (default 25).\n * @param options.pageToken - Token from a previous page's `nextPageToken`.\n * @param options.contextType - Filter to one context type (for example `\"note\"`).\n * @param options.parentUids - Exact ordered native ancestry chain for direct\n * children. Omit to leave parent unrestricted; pass `[]` for the known-empty\n * root. Native UIDs are exact tokens; for a folder's children send ancestry\n * UIDs plus the last `dataPath` token, not the hashed context-item `uid`.\n * @param options.ancestorUids - Ordered UID ancestry prefix for strict\n * descendants. Omit to leave unrestricted; pass `[]` for every item with\n * non-null ancestry.\n * @param options.connectionIds - Restrict to these connection ids. Omit to\n * leave unfiltered; pass `[]` to match none. The Files root is\n * `connectionIds: ['files']` with `parentUids: []`.\n * @returns A page of context items.\n *\n * @example\n * ```ts\n * const rootFiles = await mgmt.context.items.list({\n * connectionIds: ['files'],\n * contextType: 'file_upload',\n * parentUids: [],\n * })\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n contextType?: string\n parentUids?: readonly string[]\n ancestorUids?: readonly string[]\n connectionIds?: readonly string[]\n } = {}): Promise<Page<ContextItem>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, {\n contextType: options.contextType,\n parentUids: options.parentUids,\n ancestorUids: options.ancestorUids,\n connectionIds: options.connectionIds,\n })\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n filters: ListContextItemsFilters,\n ): Promise<Page<ContextItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_list', {\n query: contextListParams(pageSize, pageToken, filters),\n }),\n )\n return buildAipPage(data, 'contextItems', parseContextItem, (token) =>\n this.listPage(pageSize, token, filters),\n )\n }\n\n /**\n * Retrieve one context item by uid.\n *\n * @param uid - Context item uid.\n * @returns The context item.\n */\n async get(uid: string): Promise<ContextItem> {\n const data = await invokeWithRetry(this.config, this.http, 'ContextItemsController_get', {\n pathParams: { uid },\n })\n return parseContextItem(data)\n }\n\n /**\n * Update a context item.\n *\n * Only the fields you pass are changed. To clear a field, name it in\n * `updateMask` and leave its argument unset: it is sent as `null`.\n *\n * @param uid - Context item uid.\n * @param options.content - Replacement type-specific content.\n * @param options.contextType - Item type (for example `\"note\"`). Required when `content` is supplied.\n * @param options.description - New description.\n * @param options.userFeedback - Feedback verdict: `\"positive\"`, `\"neutral\"`, or `\"negative\"`.\n * @param options.topics - Replacement topic tags. Pass `[]` to clear all tags.\n * @param options.updateMask - Comma-separated field names to update or clear.\n * @returns The updated context item.\n */\n async update(\n uid: string,\n options: {\n content?: unknown\n contextType?: string\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n updateMask?: string\n } = {},\n ): Promise<ContextItem> {\n const body = updateBody({\n content: options.content,\n contextType: options.contextType,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n }, options.updateMask)\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_update', {\n pathParams: { uid },\n query: updateMaskQuery(options.updateMask),\n jsonBody: body,\n })\n return this.get(uid)\n }\n\n /**\n * Delete a context item. Deleting a Files folder also deletes all its contents.\n *\n * @param uid - Context item uid.\n * @returns Deletion confirmation details.\n */\n async delete(uid: string): Promise<ContextItemDeletion> {\n const data = await invokeWithRetry(this.config, this.http, 'ContextItemsController_delete', {\n pathParams: { uid },\n })\n return data as ContextItemDeletion\n }\n\n /**\n * Move a live file or Files folder.\n *\n * Pass `destinationFolderUid: null` to move to the Files root. The\n * destination folder must already exist. Same-parent moves succeed as a\n * no-op. Does not rename or merge folders.\n *\n * @param uid - Stored context-item uid of the file or folder to move.\n * @param options.destinationFolderUid - Stored context-item uid of the\n * destination folder, or `null` for the Files root.\n * @returns How many items changed parent (`0` is a successful no-op).\n * @throws {NotFoundError} The source is missing or not visible.\n * @throws {ModusError} The destination is missing, not a Files folder, or\n * the move would create a cycle (HTTP 400).\n * @throws {PermissionDeniedError} The destination exists but is not writable\n * for this caller.\n * @throws {ConflictError} A sibling with the same name already exists.\n *\n * @example\n * ```ts\n * const moved = await mgmt.context.items.move('PLACEHOLDER_UID', {\n * destinationFolderUid: 'PLACEHOLDER_FOLDER_UID',\n * })\n * console.log(moved.movedItems)\n * ```\n */\n async move(\n uid: string,\n options: { destinationFolderUid: string | null },\n ): Promise<ContextItemMove> {\n const data = await invokeWithRetry(\n this.config,\n this.http,\n 'ContextItemsController_move' as OperationId,\n {\n pathParams: { uid },\n jsonBody: { destinationFolderUid: options.destinationFolderUid },\n },\n )\n return data as ContextItemMove\n }\n\n /**\n * Replace who can view and manage a note, saved query, link or uploaded file.\n *\n * All three settings are required and replace the current ones. You cannot\n * remove your own manage access. An item created before items had owners\n * becomes yours on the first change.\n *\n * @param uid - UUID of the context item.\n * @param input.visibility - `shared` (the owner plus the groups in\n * `groupPermissions`) or `private` (the owner plus the users in `sharedWith`).\n * @param input.groupPermissions - Group id to `{ use, manage }`. Used only when shared.\n * @param input.sharedWith - Users such as `{ email: 'ana@example.com', permission: 'use' }`.\n * Used only when private.\n * @returns The item's new access settings and whether you can still manage it.\n * @throws {NotFoundError} The item does not exist or you cannot view it.\n * @throws {PermissionDeniedError} You can view the item but not manage it.\n * @throws {ModusError} The item is another type, a group or user is invalid,\n * or the change would remove your own manage access.\n *\n * @example\n * ```ts\n * await mgmt.context.items.updateAccess('PLACEHOLDER_UID', {\n * visibility: 'private',\n * groupPermissions: {},\n * sharedWith: [{ email: 'ana@example.com', permission: 'use' }],\n * })\n * ```\n */\n async updateAccess(\n uid: string,\n input: UpdateContextItemAccessInput,\n ): Promise<ContextItemAccessUpdate> {\n const data = await invokeWithRetry(\n this.config,\n this.http,\n 'ContextItemAccessController_updateAccess' as OperationId,\n {\n pathParams: { uid },\n jsonBody: {\n visibility: input.visibility,\n groupPermissions: input.groupPermissions,\n sharedWith: input.sharedWith,\n },\n },\n )\n return data as ContextItemAccessUpdate\n }\n}\n","import type { OperationId } from '../../_generated/operations.js'\nimport type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport type { ContextItem, CreatedContextItem } from '../../types/context.js'\nimport { withCreatedUid } from '../../types/context.js'\nimport { CustomContextItemsResource } from '../../resources/context/custom-items.js'\nimport {\n resolveAndUpdateLink,\n resolveAndUpdateNote,\n resolveAndUpdateSavedQuery,\n type UserFeedback,\n} from './_content-merge.js'\nimport { ManagementDashboardsResource } from './dashboards.js'\nimport { ManagementContextFilesResource } from './files.js'\nimport { ManagementContextItemsResource } from './items.js'\n\n/**\n * Create and update context items (notes, links, saved queries, file uploads).\n *\n * Call path: `mgmt.context` after `new ModusManagement(...)`.\n */\nexport class ManagementContextResource {\n readonly items: ManagementContextItemsResource\n readonly customItems: CustomContextItemsResource\n readonly files: ManagementContextFilesResource\n readonly dashboards: ManagementDashboardsResource\n\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {\n this.items = new ManagementContextItemsResource(http, config)\n this.customItems = new CustomContextItemsResource(http, config)\n this.files = new ManagementContextFilesResource(http, config)\n this.dashboards = new ManagementDashboardsResource(http, config)\n }\n\n /**\n * Add a free-form text note to the knowledge base.\n *\n * @param title - Note title.\n * @param content - Note body (markdown).\n * @returns The created context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const note = await mgmt.context.createNote('Runbook', '# Steps\\n1. Check logs')\n * ```\n */\n createNote(title: string, content: string): Promise<CreatedContextItem> {\n return this.create('ContextCreatorsController_createNote', omitUndefined({ title, content }))\n }\n\n /**\n * Update a note's title and markdown body.\n *\n * Preserves server-owned fields on the existing content blob. Pass `existing`\n * to skip a fetch when you already have the item from a list call.\n *\n * @param uid - Context item uid.\n * @param options.title - New title.\n * @param options.body - New markdown body.\n * @param options.existing - Optional cached item to avoid a GET.\n * @returns The updated context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const item = await mgmt.context.updateNote('PLACEHOLDER_UID', {\n * title: 'Runbook',\n * body: '# Steps\\n1. Check logs\\n2. Escalate',\n * })\n * ```\n */\n updateNote(\n uid: string,\n options: {\n title: string\n body: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n ): Promise<ContextItem> {\n return resolveAndUpdateNote(this.items, uid, options)\n }\n\n /**\n * Save a SQL query to the knowledge base.\n *\n * @param name - Display name for the query.\n * @param options.connectionId - Connection the query runs against.\n * @param options.query - SQL text.\n * @param options.path - Optional hierarchy path segments.\n * @returns The created context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const query = await mgmt.context.createSavedQuery('Monthly ARR', {\n * connectionId: 'conn_warehouse',\n * query: 'select * from arr_monthly',\n * })\n * ```\n */\n createSavedQuery(\n name: string,\n options: {\n query?: string\n connectionId: string\n description?: string\n path?: string[]\n },\n ): Promise<CreatedContextItem> {\n return this.create(\n 'ContextCreatorsController_createSavedQuery',\n omitUndefined({\n name,\n query: options.query,\n connectionId: options.connectionId,\n description: options.description,\n path: options.path,\n }),\n )\n }\n\n /**\n * Update a saved query's name, SQL, and optional connection metadata.\n *\n * @param uid - Context item uid.\n * @param options.name - New display name.\n * @param options.query - New SQL text.\n * @param options.existing - Optional cached item to avoid a GET.\n * @returns The updated context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const item = await mgmt.context.updateSavedQuery('PLACEHOLDER_UID', {\n * name: 'Monthly ARR',\n * query: 'select sum(amount) from arr_monthly',\n * })\n * ```\n */\n updateSavedQuery(\n uid: string,\n options: {\n name: string\n query: string\n connectionId?: string\n path?: string[]\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n ): Promise<ContextItem> {\n return resolveAndUpdateSavedQuery(this.items, uid, options)\n }\n\n /**\n * Add a URL to the knowledge base.\n *\n * @param url - Link URL.\n * @param options.title - Optional display title.\n * @param options.isCrawl - When true, crawl linked pages into context.\n * @param options.pageLimit - Maximum pages to crawl when `isCrawl` is true.\n * @returns The created context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const link = await mgmt.context.createLink('https://docs.example.com/runbook', {\n * title: 'Ops runbook',\n * })\n * ```\n */\n createLink(\n url: string,\n options: { title?: string; isCrawl?: boolean; pageLimit?: number } = {},\n ): Promise<CreatedContextItem> {\n return this.create(\n 'ContextCreatorsController_createLink',\n omitUndefined({\n url,\n title: options.title,\n isCrawl: options.isCrawl,\n pageLimit: options.pageLimit,\n }),\n )\n }\n\n /**\n * Update link metadata on an existing item.\n *\n * Merges `title` and/or `url` into the stored content blob. Does not re-fetch or re-crawl the URL.\n *\n * @param uid - Context item uid.\n * @param options.title - New display title.\n * @param options.url - New URL.\n * @param options.existing - Optional cached item to avoid a GET.\n * @returns The updated context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const item = await mgmt.context.updateLink('PLACEHOLDER_UID', {\n * title: 'Ops runbook (2025)',\n * })\n * ```\n */\n updateLink(\n uid: string,\n options: {\n title?: string\n url?: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n ): Promise<ContextItem> {\n return resolveAndUpdateLink(this.items, uid, options)\n }\n\n /** @internal */\n private async create(operationId: OperationId, payload: Record<string, unknown>): Promise<CreatedContextItem> {\n const data = await invokeWithRetry(this.config, this.http, operationId, {\n jsonBody: payload,\n })\n return withCreatedUid(data as Parameters<typeof withCreatedUid>[0])\n }\n}\n\nexport type { UserFeedback } from './_content-merge.js'\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../../_request.js'\nimport { validateId, validatePageSize } from '../../../_validation.js'\nimport type {\n McpExposureCatalog,\n McpExposureCatalogRequest,\n} from '../../../management/scopes/mcp-exposure-catalog.js'\nimport type { Scope } from '../../../types/scopes.js'\nimport type { VariationView } from '../../../types/views.js'\n\n/** Generated base for the management `scopes` resource. */\nexport class ScopesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List scopes.\n *\n * Returns a paginated page of scopes the caller can at least `use`. Scopes the caller cannot see\n * are filtered out. Pagination uses an opaque token returned in `nextPageToken`.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @param options.search - Case-insensitive substring filter on scope name.\n * @param options.view - Variation view. `active` reads the deployed version, or the latest draft\n * when nothing is published. `draft` reads the latest builder snapshot. `published` reads only\n * the published version, and only scopes you can use.\n * @param options.managerId - Return only scopes supervised by this manager scope id.\n * @returns A page of scopes.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {\n * console.log(scope.id, scope.name, scope.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n view?: VariationView\n managerId?: number\n } = {}): Promise<Page<Scope>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.search, options.view, options.managerId)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n view?: VariationView,\n managerId?: number,\n ): Promise<Page<Scope>> {\n const extra: Record<string, string | number> = {}\n if (search !== undefined) extra.search = search\n if (view !== undefined) extra.view = view\n if (managerId !== undefined) extra.managerId = managerId\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ScopesController_list', {\n query: aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'scopes',\n (raw) => raw as Scope,\n (token) => this.listPage(pageSize, token, search, view, managerId),\n )\n }\n\n /**\n * Get a scope.\n *\n * Returns a scope. `view=active` (default) is the deployed version, or the latest draft when\n * nothing is published. `view=draft` is the latest edits. `view=published` is only the published\n * version, and only if you can use the scope. Returns 404 if you cannot access it.\n *\n * **Requires:** `scopes:read`\n *\n * @param scopeId - Numeric scope id.\n * @param options.view - Which version to read. Defaults to `active`. `published` is only the\n * published version, and only if you can use the scope.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')\n * console.log(scope.name, scope.status)\n * ```\n */\n async get(\n scopeId: number | string,\n options: { view?: VariationView } = {},\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_get', {\n pathParams: { id: scopeId },\n query: { view: options.view },\n })\n return data as Scope\n }\n\n /**\n * Delete a scope.\n *\n * Deletes a scope. The scope can be restored later with POST /scopes/{id}/restore. Returns 404 if\n * the scope does not exist or is already deleted.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')\n * ```\n */\n async delete(scopeId: number | string): Promise<void> {\n validateId(scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, 'ScopesController_delete', {\n pathParams: { id: scopeId },\n })\n }\n\n /**\n * Preview MCP exposure catalog.\n *\n * Lists tools this scope can expose to MCP clients. A field you send replaces the current draft;\n * a field you omit stays as stored. Nothing is saved. Entries you cannot access are left out, and\n * stored selections on them are counted in hiddenSelectedCount.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n * @param request - Request body; see `McpExposureCatalogRequest`.\n *\n * @example\n * ```ts\n * const catalog = await mgmt.scopes.mcpExposureCatalog(42, {})\n * catalog.discoveryAllowed\n * ```\n */\n async mcpExposureCatalog(\n scopeId: number | string,\n request: McpExposureCatalogRequest,\n ): Promise<McpExposureCatalog> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_mcpExposureCatalog', {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined(request as Record<string, unknown>),\n })\n return data as McpExposureCatalog\n }\n\n /**\n * Restore a deleted scope.\n *\n * Restores a previously deleted scope and returns it. Restoring a scope that is already active\n * returns it unchanged.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n */\n async restore(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_restore', {\n pathParams: { id: scopeId },\n jsonBody: {},\n })\n return data as Scope\n }\n\n /**\n * Cancel ownership transfer.\n *\n * Cancels a pending ownership transfer. The current owner may cancel, the pending recipient may\n * decline, and for a scope with no owner an organization owner may cancel.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n */\n async cancelOwnershipTransfer(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_cancelOwnershipTransfer', {\n pathParams: { id: scopeId },\n })\n return data as Scope\n }\n\n /**\n * Accept ownership transfer.\n *\n * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n */\n async acceptOwnershipTransfer(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_acceptOwnershipTransfer', {\n pathParams: { id: scopeId },\n jsonBody: {},\n })\n return data as Scope\n }\n}\n","const EVERYONE_GROUP_ID = '__everyone__'\n\nexport function accessConfigWireForCreate(guardrails: string[]): Record<string, unknown> {\n return {\n visibility: 'shared',\n groupPermissions: { [EVERYONE_GROUP_ID]: { use: true, manage: true } },\n guardrails,\n sharedWith: [],\n }\n}\n\nexport function accessConfigWireForUpdate(\n existing: Record<string, unknown> | undefined,\n guardrails: string[],\n): Record<string, unknown> {\n if (!existing || Object.keys(existing).length === 0) {\n return accessConfigWireForCreate(guardrails)\n }\n return { ...existing, guardrails }\n}\n\nexport function accessFromSkillResponse(raw: Record<string, unknown>): Record<string, unknown> {\n const value = raw.accessConfig ?? raw.access_config\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n return value as Record<string, unknown>\n }\n return {}\n}\n\nexport function accessConfigBodyForCreate(\n guardrails?: string[],\n): Record<string, unknown> | undefined {\n if (guardrails === undefined) return undefined\n return accessConfigWireForCreate(guardrails)\n}\n\nexport async function accessConfigBodyForUpdate(\n guardrails: string[] | undefined,\n loadResource: () => Promise<Record<string, unknown>>,\n): Promise<Record<string, unknown> | undefined> {\n if (guardrails === undefined) return undefined\n const existing = accessFromSkillResponse(await loadResource())\n return accessConfigWireForUpdate(existing, guardrails)\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../../_pagination.js'\nimport { updateMaskQuery } from '../../../../_query.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../../../_request.js'\nimport { validateId, validatePageSize } from '../../../../_validation.js'\nimport type {\n Memory,\n MemorySearchRequest,\n MemorySearchResult,\n MemoryUpdate,\n} from '../../../../management/types/memories.js'\n\n/** Generated base for the management `scopes.memories` resource. */\nexport class ScopesMemoriesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * List scope memories.\n *\n * Returns a page of the scope’s memories (up to 1000 total). Pass `nextPageToken` as `pageToken`\n * to fetch the next page. Optional `userId` filters to one end user.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @param options.userId - Narrow results to memories tagged with this end-user id.\n * @returns A page of memories.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n userId?: string\n } = {}): Promise<Page<Memory>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.userId)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n userId?: string,\n ): Promise<Page<Memory>> {\n validateId(this.scopeId, 'scope_id')\n const extra: Record<string, string> = {}\n if (userId !== undefined) extra.userId = userId\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_list', {\n pathParams: { id: this.scopeId },\n query: aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'memories',\n (raw) => raw as Memory,\n (token) => this.listPage(pageSize, token, userId),\n )\n }\n\n /**\n * Search scope memories.\n *\n * Returns memories ranked by semantic similarity to the supplied `query`. Caller must at least\n * `use` the scope. Optional `userId` and `limit` body fields narrow the result set (legacy parity\n * with `search-memories`).\n *\n * **Requires:** `scopes:read`\n *\n * @param request - Request body; see `MemorySearchRequest`.\n */\n async search(request: MemorySearchRequest): Promise<MemorySearchResult> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_search', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined(request as Record<string, unknown>),\n })\n return data as MemorySearchResult\n }\n\n /**\n * Update a memory.\n *\n * Updates one memory. Supply at least one of `memory` or `metadata`. Use `updateMask` to limit\n * which fields change.\n *\n * **Requires:** `scopes:write`\n *\n * @param memoryId - Opaque memory id as returned by the list / search endpoints.\n * @param update - Request body; see `MemoryUpdate`.\n * @param options.updateMask - Comma-separated list of fields to update. Omit to update all\n * provided fields.\n */\n async update(\n memoryId: string,\n update: MemoryUpdate,\n options: { updateMask?: string } = {},\n ): Promise<void> {\n validateId(memoryId, 'memory_id')\n validateId(this.scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_update', {\n pathParams: { id: this.scopeId, memoryId },\n query: updateMaskQuery(options.updateMask),\n jsonBody: omitUndefined(update as Record<string, unknown>),\n })\n }\n\n /**\n * Delete a memory.\n *\n * Deletes one memory. Returns 404 if the memory does not exist or is already deleted.\n *\n * **Requires:** `scopes:write`\n *\n * @param memoryId - Opaque memory id as returned by the list / search endpoints.\n */\n async delete(memoryId: string): Promise<void> {\n validateId(memoryId, 'memory_id')\n validateId(this.scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_delete', {\n pathParams: { id: this.scopeId, memoryId },\n })\n }\n}\n","import { ScopesMemoriesResourceBase } from '../../_generated/resources/management/scopes/memories.js'\n\n/** Long-term memory stored per scope. */\nexport class ScopeMemoriesResource extends ScopesMemoriesResourceBase {}\n","import { randomUUID } from 'node:crypto'\nimport { ScopesEvaluationsResourceBase } from '../../_generated/resources/management/scopes/evaluations.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { AddEvaluationCase, EvaluationCase, UpdateEvaluationCase } from '../types/evaluations.js'\n\n/** Scheduled and manual scope evaluations. */\nexport class ScopeEvaluationsResource extends ScopesEvaluationsResourceBase {\n /**\n * Add one evaluation case and return the stored case.\n *\n * @param input.task - What the scope should do. An empty string is allowed.\n * @param input.expectedOutput - What a correct result looks like. An empty string is allowed.\n * @param input.id - Stable id. Omit it and the client assigns one before the request, so a retry sends the same id.\n * @returns The stored evaluation case, including its id.\n * @throws ConflictError An evaluation case with this id already exists. A retry after the case was stored returns this error. An identical body is not treated as success.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const added = await mgmt.scopes.evaluations(42).addCase({\n * task: \"Summarize last quarter's revenue\",\n * expectedOutput: 'A one-paragraph summary with the total',\n * })\n * console.log(added.id)\n * ```\n */\n async addCase(input: AddEvaluationCase): Promise<EvaluationCase> {\n validateId(this.scopeId, 'scope_id')\n const id = input.id ?? randomUUID()\n validateId(id, 'id')\n return await invokeWithRetry(this.config, this.http, 'ScopesController_addEvaluationCase', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined({ ...input, id }),\n }) as EvaluationCase\n }\n\n /**\n * Change the task, the expected output, or both, for one evaluation case.\n *\n * @param caseId - Id of the case to change.\n * @param patch.task - Replacement task. Omit to leave it unchanged.\n * @param patch.expectedOutput - Replacement expected output. Omit to leave it unchanged.\n * @returns The evaluation case after the change.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const updated = await mgmt.scopes.evaluations(42).updateCase('CASE_ID', {\n * task: 'Summarize revenue in two sentences',\n * })\n * console.log(updated.task)\n * ```\n */\n async updateCase(caseId: string, patch: UpdateEvaluationCase): Promise<EvaluationCase> {\n validateId(this.scopeId, 'scope_id')\n validateId(caseId, 'case_id')\n return await invokeWithRetry(this.config, this.http, 'ScopesController_updateEvaluationCase', {\n pathParams: { id: this.scopeId, caseId },\n jsonBody: omitUndefined(patch),\n }) as EvaluationCase\n }\n\n /**\n * Remove one evaluation case. The other cases stay as they are.\n *\n * @param caseId - Id of the case to remove.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.scopes.evaluations(42).deleteCase('CASE_ID')\n * ```\n */\n async deleteCase(caseId: string): Promise<void> {\n validateId(this.scopeId, 'scope_id')\n validateId(caseId, 'case_id')\n await invokeWithRetry(this.config, this.http, 'ScopesController_deleteEvaluationCase', {\n pathParams: { id: this.scopeId, caseId },\n })\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../../../_request.js'\nimport { validateId, validatePageSize } from '../../../../_validation.js'\nimport type {\n EvaluationConfig,\n EvaluationRun,\n EvaluationRunWithResults,\n TriggerEvaluationRunResponse,\n UpdateEvaluationConfig,\n} from '../../../../management/types/evaluations.js'\n\n/** Generated base for the management `scopes.evaluations` resource. */\nexport class ScopesEvaluationsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * Get evaluation configuration.\n *\n * Returns the evaluation configuration for a scope, including judge settings, schedule cadence,\n * and notification preferences.\n *\n * **Requires:** `scopes:read`\n */\n async getConfig(): Promise<EvaluationConfig> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_getConfig', {\n pathParams: { id: this.scopeId },\n })\n return data as EvaluationConfig\n }\n\n /**\n * Update evaluation configuration.\n *\n * Updates the evaluation configuration for a scope. Changes to the schedule cadence are synced\n * automatically.\n *\n * **Requires:** `scopes:write`\n *\n * @param update - Request body; see `UpdateEvaluationConfig`.\n */\n async updateConfig(update: UpdateEvaluationConfig): Promise<EvaluationConfig> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_updateConfig', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined(update as Record<string, unknown>),\n })\n return data as EvaluationConfig\n }\n\n /**\n * Trigger evaluation run.\n *\n * Triggers a manual evaluation run for the scope. The run executes asynchronously.\n *\n * **Requires:** `scopes:write`\n *\n * @returns Evaluation run accepted and queued. The run executes asynchronously; poll `GET\n * /scopes/{id}/evaluations/runs/{runId}` for status.\n */\n async triggerRun(): Promise<TriggerEvaluationRunResponse> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_triggerRun', {\n pathParams: { id: this.scopeId },\n })\n return data as TriggerEvaluationRunResponse\n }\n\n /**\n * List evaluation runs.\n *\n * Returns a paginated list of evaluation runs for the scope, ordered by most recent first.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @returns A page of runs.\n */\n listRuns(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<EvaluationRun>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listRunsPage(pageSize, options.pageToken)\n }\n\n protected async listRunsPage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<EvaluationRun>> {\n validateId(this.scopeId, 'scope_id')\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'EvaluationsController_listRuns', {\n pathParams: { id: this.scopeId },\n query: aipListParams(pageSize, pageToken) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'runs',\n (raw) => raw as EvaluationRun,\n (token) => this.listRunsPage(pageSize, token),\n )\n }\n\n /**\n * Get evaluation run.\n *\n * Returns details of an evaluation run including all per-case results.\n *\n * **Requires:** `scopes:read`\n *\n * @param runId - Run ID.\n */\n async getRun(runId: string): Promise<EvaluationRunWithResults> {\n validateId(this.scopeId, 'scope_id')\n validateId(runId, 'run_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_getRun', {\n pathParams: { id: this.scopeId, runId },\n })\n return data as EvaluationRunWithResults\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type { ScopeInterface } from '../../../../management/scopes/interfaces.js'\n\n/** Generated base for the management `scopes.interfaces` resource. */\nexport class ScopesInterfacesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * List the chat interfaces of a scope.\n *\n * Returns the chat interfaces (at most one per chat platform) that let people use this scope from\n * chat. Requires manage permission on the scope, because the config lists allowed emails.\n *\n * **Requires:** `scopes:read`\n */\n async list(): Promise<ScopeInterface[]> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_list', {\n pathParams: { id: this.scopeId },\n })\n return (data as { interfaces: ScopeInterface[] }).interfaces\n }\n\n /**\n * Remove a scope interface.\n *\n * Removes one chat interface from the scope. Mentions on that chat platform stop reaching this\n * scope immediately.\n *\n * **Requires:** `scopes:write`\n *\n * @param interfaceId - Interface id (UUID).\n */\n async delete(interfaceId: string): Promise<void> {\n validateId(this.scopeId, 'scope_id')\n validateId(interfaceId, 'interface_id')\n await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_delete', {\n pathParams: { id: this.scopeId, interfaceId },\n })\n }\n}\n","import { ScopesInterfacesResourceBase } from '../../_generated/resources/management/scopes/interfaces.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { components } from '../../_generated/v1.js'\n\nexport type ScopeInterface = components['schemas']['ScopeInterfaceDto']\nexport type AddScopeInterface = components['schemas']['AddScopeInterfaceDto']\nexport type UpdateScopeInterface = components['schemas']['UpdateScopeInterfaceDto']\n\nexport class ScopeInterfacesResource extends ScopesInterfacesResourceBase {\n\n /**\n * Add a Slack or Microsoft Teams interface to this scope.\n *\n * @param options - Interface type, optional name and config.\n * @returns The created interface.\n */\n async create(options: AddScopeInterface): Promise<ScopeInterface> {\n validateId(this.scopeId, 'scope_id')\n return await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_add', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined(options),\n }) as ScopeInterface\n }\n\n /**\n * Update an interface on this scope.\n *\n * @param interfaceId - Interface id.\n * @param options - Updated name and/or config.\n * @param updateMask - Optional comma-separated field names to update.\n * @returns The updated interface.\n */\n async update(interfaceId: string, options: UpdateScopeInterface, updateMask?: string): Promise<ScopeInterface> {\n validateId(this.scopeId, 'scope_id')\n validateId(interfaceId, 'interface_id')\n return await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_update', {\n pathParams: { id: this.scopeId, interfaceId },\n query: updateMaskQuery(updateMask),\n jsonBody: updateBody(options, updateMask),\n }) as ScopeInterface\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type {\n SetSupervisionRequest,\n Supervision,\n} from '../../../../management/scopes/supervision.js'\nimport type { SupervisionView } from '../../../../types/views.js'\n\n/** Generated base for the management `scopes.supervision` resource. */\nexport class ScopesSupervisionResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * Read the scope subordinate supervision list.\n *\n * Returns the list of subordinate scope ids managed by this scope. `?view=active` (default) reads\n * the deployed supervision set; `?view=draft` reads the most recent builder snapshot. Returns 404\n * when the caller cannot at least `use` the scope.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.view - Which variation snapshot to read. Defaults to `active`.\n */\n async get(options: { view?: SupervisionView } = {}): Promise<Supervision> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeSupervisionController_get', {\n pathParams: { id: this.scopeId },\n query: { view: options.view },\n })\n return data as Supervision\n }\n\n /**\n * Replace draft subordinate supervision list.\n *\n * Writes the supplied subordinate id list into the draft variation. Replaces the previous list\n * fully — supply an empty array to clear all subordinates. Requires manage permission on the\n * supervisor; the change is not visible to runners until the scope is deployed.\n *\n * **Requires:** `scopes:write`\n *\n * @param request - Request body; see `SetSupervisionRequest`.\n */\n async set(request: SetSupervisionRequest): Promise<Supervision> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeSupervisionController_set', {\n pathParams: { id: this.scopeId },\n jsonBody: request,\n })\n return data as Supervision\n }\n\n /**\n * Replace active subordinate supervision list.\n *\n * Writes directly into the active variation supervision set, bypassing the draft deploy cycle.\n * Requires `scopes:write` plus manage permission on the supervisor. Use to correct a live\n * supervision graph without going through the builder.\n *\n * **Requires:** `scopes:write`\n *\n * @param request - Request body; see `SetSupervisionRequest`.\n */\n async setActive(request: SetSupervisionRequest): Promise<Supervision> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeSupervisionController_setActive', {\n pathParams: { id: this.scopeId },\n jsonBody: request,\n })\n return data as Supervision\n }\n}\n","import { ScopesSupervisionResourceBase } from '../../_generated/resources/management/scopes/supervision.js'\nimport type { components } from '../../_generated/v1.js'\n\nexport type Supervision = components['schemas']['SupervisionDto']\nexport type SetSupervisionRequest = components['schemas']['SetSupervisionRequestDto']\n\nexport class ScopeSupervisionResource extends ScopesSupervisionResourceBase {}\n","import { ScopesResourceBase } from '../../_generated/resources/management/scopes.js'\nimport type { OperationId } from '../../_generated/operations.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport { ScopeConversationsResource } from '../../resources/scopes/conversations.js'\nimport type { Scope } from '../../types/scopes.js'\nimport {\n accessConfigBodyForCreate,\n accessConfigBodyForUpdate,\n} from '../_access-config.js'\nimport type { components } from '../../_generated/v1.js'\nimport type { JsonObjectListInput } from '../types/json-blob.js'\nimport type { ToolsetInput } from '../types/toolset.js'\nimport { ScopeMemoriesResource } from './memories.js'\nimport { ScopeEvaluationsResource } from './evaluations.js'\nimport { ScopeInterfacesResource } from './interfaces.js'\nimport { ScopeSupervisionResource } from './supervision.js'\n\n/** The canonical `/api/v1/scopes` management operationIds. */\ninterface ManagementScopesOperations {\n readonly list: OperationId\n readonly get: OperationId\n readonly create: OperationId\n readonly update: OperationId\n readonly deploy: OperationId\n readonly applySelectionOps: OperationId\n readonly delete: OperationId\n readonly restore: OperationId\n readonly requestOwnershipTransfer: OperationId\n readonly cancelOwnershipTransfer: OperationId\n readonly acceptOwnershipTransfer: OperationId\n readonly patchMcpConfig: OperationId\n readonly getVariation: OperationId\n}\n\n/** A connectionSet row from `scopes.get`, or a plain `{ connection_id, preferences }` object. */\ntype ConnectionSetRowInput = components['schemas']['ConnectionSetItemDto']\n\nconst MANAGEMENT_SCOPE_OPERATIONS: ManagementScopesOperations = {\n list: 'ScopesController_list',\n get: 'ScopesController_get',\n create: 'ScopesController_create',\n update: 'ScopesController_update',\n deploy: 'ScopesController_deploy',\n applySelectionOps: 'ScopesController_applySelectionOps',\n delete: 'ScopesController_delete',\n restore: 'ScopesController_restore',\n requestOwnershipTransfer: 'ScopesController_requestOwnershipTransfer',\n cancelOwnershipTransfer: 'ScopesController_cancelOwnershipTransfer',\n acceptOwnershipTransfer: 'ScopesController_acceptOwnershipTransfer',\n patchMcpConfig: 'ScopesController_patchMcpConfig',\n getVariation: 'ScopesController_getVariation',\n}\n\nfunction parseScope(raw: unknown): Scope {\n return raw as Scope\n}\n\nexport interface CreateScopeOptions {\n name: string\n description?: string\n expectedOutput?: string\n instructions?: string[]\n toolset?: ToolsetInput\n model?: string\n connectionSet?: ReadonlyArray<ConnectionSetRowInput>\n contextSelections?: JsonObjectListInput\n includeOwnLearnings?: boolean\n interfaces?: JsonObjectListInput\n guardrails?: string[]\n}\n\n/** @deprecated Use `CreateScopeOptions` instead. */\nexport type CreateSkillOptions = CreateScopeOptions\n\nexport interface UpdateScopeOptions {\n name?: string\n description?: string\n expectedOutput?: string\n instructions?: string[]\n toolset?: ToolsetInput\n model?: string\n connectionSet?: ReadonlyArray<ConnectionSetRowInput>\n contextSelections?: JsonObjectListInput\n interfaces?: JsonObjectListInput\n guardrails?: string[]\n /** Numeric id of the manager scope, or `null` to detach from the current manager. */\n managerId?: number | null\n evaluations?: JsonObjectListInput\n supervisionSubordinateDescriptions?: Record<string, string>\n updateMask?: string\n}\n\n/** @deprecated Use `UpdateScopeOptions` instead. */\nexport type UpdateSkillOptions = UpdateScopeOptions\n\n/**\n * Full CRUD and lifecycle for Modus scopes.\n *\n * Call path: `mgmt.scopes` after `new ModusManagement(...)`.\n */\nexport class ManagementScopesResource extends ScopesResourceBase {\n protected readonly ops: ManagementScopesOperations = MANAGEMENT_SCOPE_OPERATIONS\n\n /**\n * Conversations for a scope.\n *\n * @param scopeId - Scope id.\n * @returns A conversations resource scoped to the scope.\n */\n conversations(scopeId: number | string): ScopeConversationsResource {\n return new ScopeConversationsResource(this.http, this.config, scopeId)\n }\n\n /**\n * Long-term memories for a scope.\n *\n * @param scopeId - Scope id.\n * @returns A memories resource scoped to the scope.\n */\n memories(scopeId: number | string): ScopeMemoriesResource {\n return new ScopeMemoriesResource(this.http, this.config, scopeId)\n }\n\n /**\n * Evaluations for a scope.\n *\n * @param scopeId - Scope id.\n * @returns An evaluations resource scoped to the scope.\n */\n evaluations(scopeId: number | string): ScopeEvaluationsResource {\n return new ScopeEvaluationsResource(this.http, this.config, scopeId)\n }\n\n /**\n * Supervision (subordinate scopes) for a scope.\n *\n * @param scopeId - Scope id.\n * @returns A supervision resource scoped to the scope.\n */\n supervision(scopeId: number | string): ScopeSupervisionResource {\n return new ScopeSupervisionResource(this.http, this.config, scopeId)\n }\n\n /**\n * Slack and Microsoft Teams interfaces for a scope.\n *\n * @param scopeId - Scope id.\n * @returns An interfaces resource scoped to the scope.\n */\n interfaces(scopeId: number | string): ScopeInterfacesResource {\n return new ScopeInterfacesResource(this.http, this.config, scopeId)\n }\n\n /**\n * Create a new scope in the organization.\n *\n * @param options.name - Display name for the scope.\n * @param options.description - Optional description.\n * @param options.instructions - Optional system instructions.\n * @param options.model - Optional model id.\n * @param options.toolset - Optional tool selection for the scope.\n * @param options.includeOwnLearnings - Whether the scope reads what is taught while using it. Defaults to true.\n * @param options.guardrails - Runtime guardrail labels (for example `\"no-pii\"`). Omit to create with no guardrails.\n * @returns The created scope (draft).\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.create({ name: 'Support assistant', model: 'claude-sonnet-5' })\n * console.log(scope.id, scope.name)\n * ```\n */\n async create(options: CreateScopeOptions): Promise<Scope> {\n const body = omitUndefined({\n name: options.name,\n description: options.description,\n expectedOutput: options.expectedOutput,\n instructions: options.instructions,\n toolset: options.toolset,\n model: options.model,\n connectionSet: options.connectionSet,\n contextSelections: options.contextSelections,\n includeOwnLearnings: options.includeOwnLearnings,\n interfaces: options.interfaces,\n accessConfig: accessConfigBodyForCreate(options.guardrails),\n })\n const data = await invokeWithRetry(this.config, this.http, this.ops.create, {\n jsonBody: body,\n })\n return parseScope(data)\n }\n\n /**\n * Update a scope's configuration.\n *\n * Only the fields you pass are changed. To clear a field, name it in\n * `updateMask` (comma-separated field names) and leave its argument unset:\n * it is sent as `null`.\n *\n * @param scopeId - Numeric scope id.\n * @param options.guardrails - Guardrail labels to set. Fetches the current scope first to merge. Pass `[]` to clear all.\n * @param options.managerId - Numeric id of the manager scope to move this scope under, or `null`\n * to detach it. Send it alone: the server rejects it combined with other fields.\n * @param options.updateMask - Comma-separated field names to update or clear.\n * @returns The updated scope.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.update('PLACEHOLDER_SCOPE_ID', {\n * description: 'Answers billing questions for enterprise customers.',\n * })\n * ```\n */\n async update(scopeId: number | string, options: UpdateScopeOptions = {}): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const accessConfig = await accessConfigBodyForUpdate(options.guardrails, async () =>\n asRecord(\n await invokeWithRetry(this.config, this.http, this.ops.get, {\n pathParams: { id: scopeId },\n }),\n ),\n )\n const fields = {\n name: options.name,\n description: options.description,\n expectedOutput: options.expectedOutput,\n instructions: options.instructions,\n toolset: options.toolset,\n model: options.model,\n connectionSet: options.connectionSet,\n contextSelections: options.contextSelections,\n interfaces: options.interfaces,\n accessConfig,\n managerId: options.managerId,\n evaluations: options.evaluations,\n supervisionSubordinateDescriptions: options.supervisionSubordinateDescriptions,\n }\n const body = updateBody(fields, options.updateMask)\n const data = await invokeWithRetry(this.config, this.http, this.ops.update, {\n pathParams: { id: scopeId },\n query: updateMaskQuery(options.updateMask),\n jsonBody: body,\n })\n return parseScope(data)\n }\n\n /**\n * Publish the current draft of a scope.\n *\n * @param scopeId - Scope id.\n * @returns The published scope.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.create({ name: 'Support assistant' })\n * const published = await mgmt.scopes.deploy(scope.id)\n * console.log(published.status)\n * ```\n */\n async deploy(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, this.ops.deploy, {\n pathParams: { id: scopeId },\n jsonBody: {},\n }),\n )\n return parseScope(data.scope)\n }\n\n /**\n * Apply selection changes to a scope.\n *\n * Pass `validateOnly: true` to run the same checks and return the scope that would\n * be saved, without writing. Set a connection with `setConnectionPreferences` and\n * remove it with `removeConnection`.\n *\n * @param scopeId - Scope id.\n * @param ops - Selection changes, applied in order.\n * @param options.toolset - The scope toolset after the edit, when the edit changed it.\n * @param options.validateOnly - When true, check and return the planned scope without writing.\n * @returns The scope, or the scope that would be saved when `validateOnly` is true.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const preview = await mgmt.scopes.applySelectionOps(42, [{\n * op: 'setConnectionPreferences',\n * connectionId: '11111111-1111-4111-8111-111111111111',\n * preferences: { schemaVersion: 2, mode: 'all', include: [], exclude: [] },\n * }], { validateOnly: true })\n * console.log(preview.id)\n * ```\n */\n async applySelectionOps(\n scopeId: number | string,\n ops: ReadonlyArray<Record<string, unknown>>,\n options?: { toolset?: Record<string, unknown>; validateOnly?: boolean },\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, this.ops.applySelectionOps, {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({\n ops,\n toolset: options?.toolset,\n validateOnly: options?.validateOnly ? true : undefined,\n }),\n })\n return parseScope(data)\n }\n\n /**\n * Start transferring ownership of a scope to another organization member.\n *\n * The current owner calls this, and the recipient accepts. A scope with no owner (one\n * created with a service-account token) can be given one by an organization owner;\n * assigning yourself takes effect at once.\n *\n * @param scopeId - Scope id.\n * @param options.newOwnerUserId - User id of the proposed new owner.\n * @returns The scope with a pending ownership transfer.\n */\n async requestOwnershipTransfer(\n scopeId: number | string,\n options: { newOwnerUserId: string },\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(\n this.config,\n this.http,\n this.ops.requestOwnershipTransfer,\n {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({ newOwnerUserId: options.newOwnerUserId }),\n },\n )\n return parseScope(data)\n }\n\n /**\n * Update MCP server configuration for a scope.\n *\n * @param scopeId - Scope id.\n * @param options.mcpConfig - MCP configuration object.\n */\n async patchMcpConfig(\n scopeId: number | string,\n options: { mcpConfig: Record<string, unknown> },\n ): Promise<void> {\n validateId(scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, this.ops.patchMcpConfig, {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({ config: options.mcpConfig }),\n })\n }\n\n /**\n * Retrieve a specific scope variation by uid.\n *\n * @param scopeId - Scope id.\n * @param options.variationUid - Variation uid.\n * @returns The scope variation.\n */\n async getVariation(\n scopeId: number | string,\n options: { variationUid: string },\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n validateId(options.variationUid, 'variation_uid')\n const data = await invokeWithRetry(this.config, this.http, this.ops.getVariation, {\n pathParams: { id: scopeId, variationUid: options.variationUid },\n })\n return parseScope(data)\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { invokeWithRetry } from '../../../_request.js'\nimport type { UsageUsersReport } from '../../../types/usage.js'\n\n/** Generated base for the management `usage` resource. */\nexport class UsageResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List usage users.\n *\n * Returns the distinct acting-user emails that appear in your organization's LLM usage over the\n * `[since, until)` window. Feeds the usage page's user filter (includes non-Modus Slack/Teams\n * users). Scoped to your organization.\n *\n * **Requires:** `usage:read`\n *\n * @param options.since - ISO8601 start of the query window (inclusive).\n * @param options.until - ISO8601 end of the query window (exclusive).\n */\n async listUsers(options: { since: string; until: string }): Promise<UsageUsersReport> {\n const data = await invokeWithRetry(this.config, this.http, 'UsageController_listUsers', {\n query: { since: options.since, until: options.until },\n })\n return data as UsageUsersReport\n }\n}\n","import { UsageResourceBase } from '../_generated/resources/management/usage.js'\nimport { invokeWithRetry } from '../_request.js'\nimport type { UsageReport, UsageRollup } from '../types/usage.js'\n\nexport class ManagementUsageResource extends UsageResourceBase {\n /**\n * List usage metrics for your organization over a time window.\n *\n * @param options.since - Start of the window (ISO 8601, inclusive).\n * @param options.until - End of the window (ISO 8601, exclusive).\n * @param options.rollup - Bucket size for each row: `\"hour\"` or `\"day\"`.\n * @param options.model - Optional filter to a single model name.\n * @param options.userEmail - Optional filter to one or more acting-user emails.\n * @returns Usage report rows for the window.\n * @throws {UnprocessableError} When the request is rejected by the API.\n * @throws {AuthenticationError} When the API key is invalid or missing.\n */\n async list(options: {\n since: string\n until: string\n rollup: UsageRollup\n model?: string\n userEmail?: readonly string[]\n }): Promise<UsageReport> {\n const query: Record<string, string | string[]> = {\n since: options.since,\n until: options.until,\n rollup: options.rollup,\n }\n if (options.model !== undefined) query.model = options.model\n if (options.userEmail !== undefined) query.user_email = [...options.userEmail]\n const data = await invokeWithRetry(this.config, this.http, 'UsageController_list', { query })\n return data as UsageReport\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../../_request.js'\nimport { validatePageSize } from '../../../_validation.js'\nimport type { ToolCatalogEntry } from '../../../types/tools.js'\n\n/** Generated base for the management `tools` resource. */\nexport class ToolsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List available tools.\n *\n * Returns a page of known tool/integration surfaces a scope can select in its toolset, with the\n * fixed actions for built-in tools.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @returns A page of tools.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<ToolCatalogEntry>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<ToolCatalogEntry>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ToolsController_list', {\n query: aipListParams(pageSize, pageToken) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'tools',\n (raw) => raw as ToolCatalogEntry,\n (token) => this.listPage(pageSize, token),\n )\n }\n}\n","import { ToolsResourceBase } from '../_generated/resources/management/tools.js'\n\n/** Browse the catalog of tool and integration surfaces a scope can select in its toolset. */\nexport class ManagementToolsResource extends ToolsResourceBase {}\n","import type { ModusConfig } from '../_config.js'\nimport type { components } from '../_generated/v1.js'\nimport type { HttpClient } from '../_http.js'\nimport { invokeWithRetry } from '../_request.js'\n\nexport type MemberGroup = components['schemas']['MemberGroupDto']\nexport type OrgMember = components['schemas']['OrgMemberDto']\n\nexport class ManagementUsersResource {\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /** List member groups in the organization. */\n async listMemberGroups(): Promise<MemberGroup[]> {\n const data = (await invokeWithRetry(\n this.config, this.http, 'MemberGroupsController_list',\n )) as { groups: MemberGroup[] }\n return data.groups\n }\n\n /** List organization members. */\n async listOrgMembers(): Promise<OrgMember[]> {\n const data = (await invokeWithRetry(\n this.config, this.http, 'OrgMembersController_list',\n )) as { members: OrgMember[] }\n return data.members\n }\n}\n","import { ModusClientBase } from '../_client-base.js'\nimport type { ModusOptions } from '../_config.js'\nimport { ManagementWorkflowsResource } from './workflows/agents.js'\nimport { ManagementContextResource } from './context/context.js'\nimport { ManagementScopesResource } from './scopes/skills.js'\nimport { ManagementUsageResource } from './usage.js'\nimport { ManagementToolsResource } from './tools.js'\nimport { ManagementUsersResource } from './users.js'\n\n/**\n * Configure scopes, workflows, context, usage, tools, and users.\n *\n * Call path: `const mgmt = new ModusManagement(...)` then `mgmt.scopes`, `mgmt.context`, …\n *\n * @param options - Client configuration (`apiKey`, `baseUrl`, `timeoutMs`, `maxRetries`).\n */\nexport class ModusManagement extends ModusClientBase {\n readonly scopes: ManagementScopesResource\n readonly workflows: ManagementWorkflowsResource\n readonly context: ManagementContextResource\n readonly usage: ManagementUsageResource\n readonly tools: ManagementToolsResource\n readonly users: ManagementUsersResource\n\n constructor(options: ModusOptions = {}) {\n super(options)\n this.scopes = new ManagementScopesResource(this.http, this.config)\n this.workflows = new ManagementWorkflowsResource(this.http, this.config)\n this.context = new ManagementContextResource(this.http, this.config)\n this.usage = new ManagementUsageResource(this.http, this.config)\n this.tools = new ManagementToolsResource(this.http, this.config)\n this.users = new ManagementUsersResource(this.http, this.config)\n }\n}\n\nexport type { ModusOptions }\nexport type { ModusConfig } from '../_config.js'\nexport type { ManagementScopesResource } from './scopes/skills.js'\nexport type { ScopeMemoriesResource } from './scopes/memories.js'\nexport type { ScopeEvaluationsResource } from './scopes/evaluations.js'\nexport type { ScopeSupervisionResource, SetSupervisionRequest, Supervision } from './scopes/supervision.js'\nexport type { McpExposureCatalog, McpExposureCatalogRequest } from './scopes/mcp-exposure-catalog.js'\nexport type {\n AddScopeInterface,\n ScopeInterface,\n ScopeInterfacesResource,\n UpdateScopeInterface,\n} from './scopes/interfaces.js'\nexport type { ManagementWorkflowsResource } from './workflows/agents.js'\nexport type {\n AddAgentInterface,\n AgentInterface,\n UpdateAgentInterface,\n WorkflowInterfacesResource,\n} from './workflows/interfaces.js'\nexport type { ManagementContextResource } from './context/context.js'\nexport type { ManagementContextItemsResource } from './context/items.js'\nexport type { BatchUploadOptions, ManagementContextFilesResource } from './context/files.js'\nexport type { ManagementDashboardElementsResource, ManagementDashboardsResource } from './context/dashboards.js'\nexport type { ManagementUsageResource } from './usage.js'\nexport type { ManagementToolsResource } from './tools.js'\nexport type { ManagementUsersResource, MemberGroup, OrgMember } from './users.js'\nexport type {\n AddEvaluationCase,\n EvaluationCase,\n EvaluationConfig,\n EvaluationRun,\n EvaluationRunWithResults,\n TriggerEvaluationRunResponse,\n UpdateEvaluationCase,\n UpdateEvaluationConfig,\n} from './types/evaluations.js'\nexport type { JsonObjectInput, JsonObjectListInput } from './types/json-blob.js'\nexport type { CreatedContextItem } from '../types/context.js'\nexport type { ToolCatalogEntry } from '../types/tools.js'\nexport type {\n UsageBucket,\n UsageReport,\n UsageRollup,\n UsageTotals,\n UsageUser,\n UsageUsersReport,\n} from '../types/usage.js'\nexport type {\n CreateScopeOptions,\n UpdateScopeOptions,\n CreateSkillOptions,\n UpdateSkillOptions,\n} from './scopes/skills.js'\nexport type {\n CreateWorkflowOptions,\n UpdateWorkflowOptions,\n CreateAgentOptions,\n UpdateAgentOptions,\n TriggerInput,\n AgentSelectionInput,\n WorkflowGraphInput,\n} from './workflows/agents.js'\nexport type { UserFeedback } from './context/context.js'\nexport type {\n ContextItemAccessUpdate,\n ContextItemDeletion,\n ContextItemMove,\n UpdateContextItemAccessInput,\n} from '../types/context.js'\nexport type {\n BulkFinalizeResult,\n BulkUploadFromUrlsResult,\n BulkUploadUrlsResult,\n FinalizeInput,\n FailedUploadFromUrl,\n FailedUploadUrl,\n FinalizeFailure,\n FileUpload,\n FileUploadStatus,\n UploadDirFailure,\n UploadDirResult,\n UploadFileInput,\n UploadFromUrlInput,\n UploadProgress,\n UploadProgressCallback,\n UploadUrlInput,\n UploadUrlSlot,\n WaitUntil,\n} from '../types/context-files.js'\nexport type {\n CreateDashboardElementInput,\n CreateDashboardInput,\n Dashboard,\n DashboardDraftSnapshot,\n DashboardElementKind,\n DashboardElementLayout,\n DashboardElementPatch,\n DashboardElementResult,\n DashboardElementsList,\n DashboardElementSummary,\n DashboardLayoutElement,\n DashboardPublishResult,\n DashboardVersion,\n DashboardView,\n PublishDashboardInput,\n TransferDashboardOwnershipInput,\n UpdateDashboardAccessInput,\n UpdateDashboardDraftInput,\n UpdateDashboardElementInput,\n UpdateDashboardLayoutInput,\n} from '../types/context-dashboards.js'\nexport type { PlatformToolsetEntry, ToolsetInput, ToolsetRules, ToolsetSlot } from './types/toolset.js'\nexport type {\n Memory,\n MemorySearchRequest,\n MemorySearchResult,\n MemoryUpdate,\n} from './types/memories.js'\n"],"mappings":";;;;;;;;;;;;;;;;AAWO,IAAM,wBAAN,MAA4B;AAAA;AAAA,EAEjC,YACqB,MACA,QACnB;AAFmB;AACA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8BH,KAAK,UAOD,CAAC,GAA4B;AAC/B,UAAM,WAAW,QAAQ,YAAY;AACrC,qBAAiB,QAAQ;AACzB,WAAO,KAAK,SAAS,UAAU,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,MAAM,QAAQ,MAAM,QAAQ,gBAAgB;AAAA,EACxH;AAAA,EAEA,MAAgB,SACd,UACA,WACA,QACA,MACA,MACA,kBACyB;AACzB,UAAM,QAA0C,CAAC;AACjD,QAAI,WAAW,OAAW,OAAM,SAAS;AACzC,QAAI,SAAS,OAAW,OAAM,OAAO;AACrC,QAAI,SAAS,OAAW,OAAM,OAAO;AACrC,QAAI,qBAAqB,OAAW,OAAM,mBAAmB;AAC7D,UAAM,OAAO;AAAA,MACX,MAAM,gBAAgB,KAAK,QAAQ,KAAK,MAAM,4BAA4B;AAAA,QACxE,OAAO,cAAc,UAAU,WAAW,KAAK;AAAA,MAIjD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,CAAC,QAAQ;AAAA,MACT,CAAC,UAAU,KAAK,SAA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BAA2C;AAC/C,UAAM,OAAQ,MAAM;AAAA,MAClB,KAAK;AAAA,MAAQ,KAAK;AAAA,MAAM;AAAA,IAC1B;AACA,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,MAAM,iBAAuC;AAC3C,UAAM,OAAQ,MAAM;AAAA,MAClB,KAAK;AAAA,MAAQ,KAAK;AAAA,MAAM;AAAA,IAC1B;AACA,WAAO,KAAK;AAAA,EACd;AACF;;;ACbO,IAAM,kBAAN,cAA8B,gBAAgB;AAAA,EAQnD,YAAY,UAAwB,CAAC,GAAG;AACtC,UAAM,OAAO;AACb,SAAK,SAAS,IAAI,yBAAyB,KAAK,MAAM,KAAK,MAAM;AACjE,SAAK,YAAY,IAAI,4BAA4B,KAAK,MAAM,KAAK,MAAM;AACvE,SAAK,UAAU,IAAI,0BAA0B,KAAK,MAAM,KAAK,MAAM;AACnE,SAAK,QAAQ,IAAI,wBAAwB,KAAK,MAAM,KAAK,MAAM;AAC/D,SAAK,QAAQ,IAAI,wBAAwB,KAAK,MAAM,KAAK,MAAM;AAC/D,SAAK,QAAQ,IAAI,wBAAwB,KAAK,MAAM,KAAK,MAAM;AAAA,EACjE;AACF;","names":["relative"]}
|
|
1
|
+
{"version":3,"sources":["../../src/_generated/resources/management/workflows.ts","../../src/_query.ts","../../src/_generated/resources/management/workflows/interfaces.ts","../../src/management/workflows/interfaces.ts","../../src/management/workflows/agents.ts","../../src/types/context.ts","../../src/management/context/_content-merge.ts","../../src/_generated/resources/management/context/dashboards.ts","../../src/_generated/resources/management/context/dashboards/elements.ts","../../src/management/context/dashboards.ts","../../src/management/context/files.ts","../../src/_generated/resources/management/context/files.ts","../../src/management/context/items.ts","../../src/management/context/context.ts","../../src/_generated/resources/management/scopes.ts","../../src/management/_access-config.ts","../../src/_generated/resources/management/scopes/memories.ts","../../src/management/scopes/memories.ts","../../src/management/scopes/evaluations.ts","../../src/_generated/resources/management/scopes/evaluations.ts","../../src/_generated/resources/management/scopes/interfaces.ts","../../src/management/scopes/interfaces.ts","../../src/_generated/resources/management/scopes/supervision.ts","../../src/management/scopes/supervision.ts","../../src/management/scopes/skills.ts","../../src/_generated/resources/management/usage.ts","../../src/management/usage.ts","../../src/_generated/resources/management/tools.ts","../../src/management/tools.ts","../../src/management/users.ts","../../src/management/index.ts"],"sourcesContent":["// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../../_request.js'\nimport { validateId, validatePageSize } from '../../../_validation.js'\nimport type { VariationView } from '../../../types/views.js'\nimport type { Workflow, WorkflowType } from '../../../types/workflows.js'\n\n/** Generated base for the management `workflows` resource. */\nexport class WorkflowsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List workflows.\n *\n * Returns a paginated page of workflows the caller can at least `use`. Workflows the caller\n * cannot see are filtered out. Pagination uses an opaque token returned in `nextPageToken`.\n *\n * **Requires:** `workflows:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @param options.search - Case-insensitive substring filter on workflow name.\n * @param options.type - Filter by workflow type.\n * @param options.view - Variation view. `active` reads the deployed version. `draft` reads the\n * latest builder snapshot. `published` reads only a published workflow of type workflow that\n * you can use; tasks are excluded.\n * @param options.includeVariation - Include the requested variation payload (`trigger`,\n * `workflowStructure`, `agentSelection`) on list rows.\n * @returns A page of workflows.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * for await (const wf of (await mgmt.workflows.list({ search: 'digest' })).autoPagingIter()) {\n * console.log(wf.id, wf.name, wf.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n type?: WorkflowType\n view?: VariationView\n includeVariation?: boolean\n } = {}): Promise<Page<Workflow>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.search, options.type, options.view, options.includeVariation)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n type?: WorkflowType,\n view?: VariationView,\n includeVariation?: boolean,\n ): Promise<Page<Workflow>> {\n const extra: Record<string, string | boolean> = {}\n if (search !== undefined) extra.search = search\n if (type !== undefined) extra.type = type\n if (view !== undefined) extra.view = view\n if (includeVariation !== undefined) extra.includeVariation = includeVariation\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'WorkflowsController_list', {\n query: aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'workflows',\n (raw) => raw as Workflow,\n (token) => this.listPage(pageSize, token, search, type, view, includeVariation),\n )\n }\n\n /**\n * Delete a workflow.\n *\n * Deletes a workflow and stops its schedule. The workflow can be restored later with POST\n * /workflows/{id}/restore. Returns 404 if the workflow does not exist or is already deleted.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.workflows.delete('PLACEHOLDER_WORKFLOW_ID')\n * ```\n */\n async delete(workflowId: number | string): Promise<void> {\n validateId(workflowId, 'workflow_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowsController_delete', {\n pathParams: { id: workflowId },\n })\n }\n\n /**\n * Restore a deleted workflow.\n *\n * Restores a previously deleted workflow and returns it. The workflow’s schedule is not resumed\n * automatically — re-enable it if it should run again. Restoring an active workflow returns it\n * unchanged.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n */\n async restore(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_restore', {\n pathParams: { id: workflowId },\n jsonBody: {},\n })\n return data as Workflow\n }\n\n /**\n * Cancel ownership transfer.\n *\n * Cancels a pending ownership transfer. The current owner may cancel; the pending recipient may\n * decline.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n */\n async cancelOwnershipTransfer(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_cancelOwnershipTransfer', {\n pathParams: { id: workflowId },\n })\n return data as Workflow\n }\n\n /**\n * Accept ownership transfer.\n *\n * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.\n *\n * **Requires:** `workflows:write`\n *\n * @param workflowId - Numeric workflow id.\n */\n async acceptOwnershipTransfer(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_acceptOwnershipTransfer', {\n pathParams: { id: workflowId },\n jsonBody: {},\n })\n return data as Workflow\n }\n}\n","import { ValidationError } from './_exceptions.js'\n\nexport function updateMaskQuery(\n updateMask?: string,\n): Record<string, string> | undefined {\n if (updateMask === undefined) return undefined\n if (!updateMask.trim()) {\n throw new ValidationError('update_mask must be a non-empty comma-separated list of field names')\n }\n return { updateMask }\n}\n\n/**\n * A PATCH body: the fields the caller set, plus `null` for each masked field left unset.\n *\n * The server writes only fields that are both in the mask and present in the body, so a masked\n * field left unset must go on the wire as `null` to be cleared. A nested mask path\n * (`accessConfig.visibility`) never nulls its root object.\n */\nexport function updateBody(fields: object, updateMask?: string): Record<string, unknown> {\n const body: Record<string, unknown> = Object.fromEntries(\n Object.entries(fields).filter(([, value]) => value !== undefined),\n )\n for (const field of updateMask?.split(',') ?? []) {\n const name = field.trim()\n if (name && !name.includes('.') && !(name in body)) body[name] = null\n }\n return body\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type { AgentInterface } from '../../../../management/workflows/interfaces.js'\n\n/** Generated base for the management `workflows.interfaces` resource. */\nexport class WorkflowsInterfacesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly workflowId: number | string,\n ) {}\n\n /**\n * List interfaces attached to a workflow.\n *\n * Returns every Slack, MCP, or Teams interface bound to the workflow. Requires manage permission\n * on the workflow: returns 403 if you can only use it, and 404 if you cannot access it.\n *\n * **Requires:** `workflows:read`\n */\n async list(): Promise<AgentInterface[]> {\n validateId(this.workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_list', {\n pathParams: { id: this.workflowId },\n })\n return (data as { interfaces: AgentInterface[] }).interfaces\n }\n\n /**\n * Remove every interface from a workflow.\n *\n * Deletes all interface rows attached to the workflow. Useful when recreating the interface set\n * from scratch.\n *\n * **Requires:** `workflows:write`\n */\n async deleteAll(): Promise<void> {\n validateId(this.workflowId, 'workflow_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_deleteAll', {\n pathParams: { id: this.workflowId },\n })\n }\n\n /**\n * Remove a workflow interface.\n *\n * Deletes one interface row. For MCP interfaces, bound MCP tokens are revoked best-effort.\n *\n * **Requires:** `workflows:write`\n *\n * @param interfaceId - Interface row id (UUID).\n */\n async delete(interfaceId: string): Promise<void> {\n validateId(this.workflowId, 'workflow_id')\n validateId(interfaceId, 'interface_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_delete', {\n pathParams: { id: this.workflowId, interfaceId },\n })\n }\n}\n","import { WorkflowsInterfacesResourceBase } from '../../_generated/resources/management/workflows/interfaces.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { components } from '../../_generated/v1.js'\n\nexport type AgentInterface = components['schemas']['AgentInterfaceDto']\nexport type AddAgentInterface = components['schemas']['AddAgentInterfaceDto']\nexport type UpdateAgentInterface = components['schemas']['UpdateAgentInterfaceDto']\n\nexport class WorkflowInterfacesResource extends WorkflowsInterfacesResourceBase {\n\n /**\n * Add an interface to this workflow.\n *\n * @param options - Interface configuration to attach.\n * @returns The created interface.\n */\n async create(options: AddAgentInterface): Promise<AgentInterface> {\n validateId(this.workflowId, 'workflow_id')\n return await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_add', {\n pathParams: { id: this.workflowId },\n jsonBody: omitUndefined(options),\n }) as AgentInterface\n }\n\n /**\n * Update an interface attached to this workflow.\n *\n * @param interfaceId - Interface id.\n * @param options - Updated interface values.\n * @param updateMask - Optional comma-separated field names to update.\n * @returns The updated interface.\n */\n async update(interfaceId: string, options: UpdateAgentInterface, updateMask?: string): Promise<AgentInterface> {\n validateId(this.workflowId, 'workflow_id')\n validateId(interfaceId, 'interface_id')\n return await invokeWithRetry(this.config, this.http, 'WorkflowInterfacesController_update', {\n pathParams: { id: this.workflowId, interfaceId },\n query: updateMaskQuery(updateMask),\n jsonBody: updateBody(options, updateMask),\n }) as AgentInterface\n }\n}\n","import { WorkflowsResourceBase } from '../../_generated/resources/management/workflows.js'\nimport type { OperationId } from '../../_generated/operations.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { Workflow, WorkflowType } from '../../types/workflows.js'\nimport type { VariationView } from '../../types/views.js'\nimport { WorkflowInterfacesResource } from './interfaces.js'\n\nexport type TriggerInput = Record<string, unknown>\nexport type AgentSelectionInput = Record<string, unknown>\nexport type WorkflowGraphInput = Record<string, unknown>\n\n/** The canonical `/api/v1/workflows` management operationIds. */\ninterface ManagementWorkflowsOperations {\n readonly list: OperationId\n readonly get: OperationId\n readonly create: OperationId\n readonly update: OperationId\n readonly deploy: OperationId\n readonly delete: OperationId\n readonly restore: OperationId\n readonly requestOwnershipTransfer: OperationId\n readonly cancelOwnershipTransfer: OperationId\n readonly acceptOwnershipTransfer: OperationId\n readonly toggle: OperationId\n}\n\nconst MANAGEMENT_WORKFLOW_OPERATIONS: ManagementWorkflowsOperations = {\n list: 'WorkflowsController_list',\n get: 'WorkflowsController_get',\n create: 'WorkflowsController_create',\n update: 'WorkflowsController_update',\n deploy: 'WorkflowsController_deploy',\n delete: 'WorkflowsController_delete',\n restore: 'WorkflowsController_restore',\n requestOwnershipTransfer: 'WorkflowsController_requestOwnershipTransfer',\n cancelOwnershipTransfer: 'WorkflowsController_cancelOwnershipTransfer',\n acceptOwnershipTransfer: 'WorkflowsController_acceptOwnershipTransfer',\n toggle: 'WorkflowsController_toggle',\n}\n\nfunction parseWorkflow(raw: unknown): Workflow {\n return raw as Workflow\n}\n\nexport interface CreateWorkflowOptions {\n name: string\n type: WorkflowType\n description?: string\n trigger?: TriggerInput\n agentSelection?: AgentSelectionInput\n workflowStructure?: WorkflowGraphInput\n}\n\n/** @deprecated Use `CreateWorkflowOptions` instead. */\nexport type CreateAgentOptions = CreateWorkflowOptions\n\nexport interface UpdateWorkflowOptions {\n name?: string\n type?: WorkflowType\n description?: string\n trigger?: TriggerInput\n agentSelection?: AgentSelectionInput\n workflowStructure?: WorkflowGraphInput\n updateMask?: string\n}\n\n/** @deprecated Use `UpdateWorkflowOptions` instead. */\nexport type UpdateAgentOptions = UpdateWorkflowOptions\n\nexport class ManagementWorkflowsResource extends WorkflowsResourceBase {\n protected readonly ops: ManagementWorkflowsOperations = MANAGEMENT_WORKFLOW_OPERATIONS\n\n /**\n * Retrieve a workflow with full configuration.\n *\n * @param workflowId - Numeric workflow id.\n * @param options.view - Variation view: `\"active\"` (deployed), `\"draft\"`, or `\"published\"` (published workflow you can use).\n * @returns The workflow.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const [first] = (await mgmt.workflows.list()).items\n * const wf = await mgmt.workflows.get(first.id)\n * console.log(wf.name, wf.status)\n * ```\n */\n async get(workflowId: number | string, options: { view?: VariationView } = {}): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const query = options.view !== undefined ? { view: options.view } : undefined\n const data = await invokeWithRetry(this.config, this.http, this.ops.get, {\n pathParams: { id: workflowId },\n query,\n })\n return parseWorkflow(data)\n }\n\n /**\n * Interfaces attached to a workflow.\n *\n * @param workflowId - Workflow id.\n * @returns An interfaces resource scoped to the workflow.\n */\n interfaces(workflowId: number | string): WorkflowInterfacesResource {\n return new WorkflowInterfacesResource(this.http, this.config, workflowId)\n }\n\n /**\n * Create a new workflow in the organization.\n *\n * @param options.name - Display name for the workflow.\n * @param options.type - `\"workflow\"`. `\"task\"` is a deprecated alias the server stores as `\"workflow\"`.\n * @param options.trigger - Optional trigger configuration.\n * @returns The created workflow (draft).\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const wf = await mgmt.workflows.create({ name: 'Daily report', type: 'workflow' })\n * ```\n */\n async create(options: CreateWorkflowOptions): Promise<Workflow> {\n const body = omitUndefined({\n name: options.name,\n type: options.type,\n description: options.description,\n trigger: options.trigger,\n agentSelection: options.agentSelection,\n workflowStructure: options.workflowStructure,\n })\n const data = await invokeWithRetry(this.config, this.http, this.ops.create, {\n jsonBody: body,\n })\n return parseWorkflow(data)\n }\n\n /**\n * Update a workflow's configuration.\n *\n * Only the fields you pass are changed. To clear a field, name it in\n * `updateMask` and leave its argument unset: it is sent as `null`.\n *\n * @param workflowId - Numeric workflow id.\n * @param options.type - Only `\"workflow\"` is accepted; `\"task\"` is rejected with a 422.\n * @param options.updateMask - Comma-separated field names to update or clear.\n * @returns The updated workflow.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const wf = await mgmt.workflows.update('PLACEHOLDER_WORKFLOW_ID', { description: 'Runs every morning' })\n * ```\n */\n async update(workflowId: number | string, options: UpdateWorkflowOptions = {}): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const fields = {\n name: options.name,\n type: options.type,\n description: options.description,\n trigger: options.trigger,\n agentSelection: options.agentSelection,\n workflowStructure: options.workflowStructure,\n }\n const body = updateBody(fields, options.updateMask)\n const data = await invokeWithRetry(this.config, this.http, this.ops.update, {\n pathParams: { id: workflowId },\n query: updateMaskQuery(options.updateMask),\n jsonBody: body,\n })\n return parseWorkflow(data)\n }\n\n /**\n * Publish the current draft of a workflow.\n *\n * @param workflowId - Workflow id.\n * @returns The published workflow.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.workflows.update('PLACEHOLDER_WORKFLOW_ID', { description: 'Runs every morning' })\n * const published = await mgmt.workflows.deploy('PLACEHOLDER_WORKFLOW_ID')\n * ```\n */\n async deploy(workflowId: number | string): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, this.ops.deploy, {\n pathParams: { id: workflowId },\n jsonBody: {},\n }),\n )\n return parseWorkflow(data.workflow)\n }\n\n /**\n * Enable or disable a workflow without deleting it.\n *\n * @param workflowId - Workflow id.\n * @param options.active - `true` to activate, `false` to deactivate.\n * @returns The updated workflow.\n */\n async toggle(workflowId: number | string, options: { active: boolean }): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(this.config, this.http, this.ops.toggle, {\n pathParams: { id: workflowId },\n jsonBody: { active: options.active },\n })\n return parseWorkflow(data)\n }\n\n /**\n * Start transferring ownership of a workflow to another organization member.\n *\n * @param workflowId - Workflow id.\n * @param options.newOwnerUserId - User id of the proposed new owner.\n * @returns The workflow with a pending ownership transfer.\n */\n async requestOwnershipTransfer(\n workflowId: number | string,\n options: { newOwnerUserId: string },\n ): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const data = await invokeWithRetry(\n this.config,\n this.http,\n this.ops.requestOwnershipTransfer,\n {\n pathParams: { id: workflowId },\n jsonBody: omitUndefined({ newOwnerUserId: options.newOwnerUserId }),\n },\n )\n return parseWorkflow(data)\n }\n}\n","import type { components } from '../_generated/v1.js'\n\nexport type ContextItem = components['schemas']['ContextItemDto']\nexport type ContextItemAncestor = components['schemas']['ContextItemAncestorDto']\nexport type ContextItemLookupRow = components['schemas']['LookupContextItemRowDto']\nexport type ContextItemsQuery = components['schemas']['QueryContextItemsRequestDto']\nexport type ContextItemsQueryResult = components['schemas']['QueryContextItemsResponseDto']\nexport type ContextItemDeletion = components['schemas']['DeleteContextItemResponseDto']\nexport type ContextItemMove = components['schemas']['MoveContextItemResponseDto']\n/** Input for `updateAccess()`; all three settings replace the current ones. */\nexport type UpdateContextItemAccessInput = components['schemas']['UpdateContextItemAccessDto']\n/** Who can view and manage an item after `updateAccess()`. */\nexport type ContextItemAccessUpdate = components['schemas']['ContextItemAccessResponseDto']\n/** Create response; ``uid`` mirrors ``contextItemId`` for list/get parity. */\nexport type CreatedContextItem = components['schemas']['CreatedContextItemResponseDto'] & {\n uid: string\n}\nexport type ContextType = string\n\nexport function withCreatedUid(\n data: components['schemas']['CreatedContextItemResponseDto'],\n): CreatedContextItem {\n return { ...data, uid: data.contextItemId }\n}\n","import { ValidationError } from '../../_exceptions.js'\nimport type { ContextItem } from '../../types/context.js'\nimport type { ManagementContextItemsResource } from './items.js'\n\nexport type UserFeedback = 'positive' | 'neutral' | 'negative'\n\nfunction requireContentDict(item: ContextItem, contextType: string): Record<string, unknown> {\n if (item.contextType !== contextType) {\n throw new ValidationError(`Expected contextType ${contextType}, got ${item.contextType}.`)\n }\n if (!item.content || typeof item.content !== 'object' || Array.isArray(item.content)) {\n throw new ValidationError(`Context item ${item.uid} has no object content; cannot merge ${contextType} fields.`)\n }\n return item.content as Record<string, unknown>\n}\n\nexport function mergeNoteContent(\n existing: Record<string, unknown>,\n options: { title: string; body: string },\n): Record<string, unknown> {\n return { ...existing, title: options.title, content: options.body }\n}\n\nexport function mergeLinkContent(\n existing: Record<string, unknown>,\n options: { title?: string; url?: string },\n): Record<string, unknown> {\n const merged = { ...existing }\n if (options.title !== undefined) merged.title = options.title\n if (options.url !== undefined) merged.url = options.url\n return merged\n}\n\nexport function mergeSavedQueryContent(\n existing: Record<string, unknown>,\n options: {\n name: string\n query: string\n connectionId?: string\n path?: string[]\n },\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...existing, name: options.name, query: options.query }\n if (options.connectionId !== undefined) merged.connectionId = options.connectionId\n if (options.path !== undefined) merged.path = options.path\n return merged\n}\n\nasync function resolveExistingContent(\n items: ManagementContextItemsResource,\n uid: string,\n contextType: string,\n existing?: ContextItem,\n): Promise<Record<string, unknown>> {\n const item = existing ?? (await items.get(uid))\n return requireContentDict(item, contextType)\n}\n\nexport async function updateWithMergedContent(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n contextType: string\n mergedContent: Record<string, unknown>\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n if (options.existing) requireContentDict(options.existing, options.contextType)\n return items.update(uid, {\n contextType: options.contextType,\n content: options.mergedContent,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n\nexport async function resolveAndUpdateNote(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n title: string\n body: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n const content = await resolveExistingContent(items, uid, 'note', options.existing)\n return updateWithMergedContent(items, uid, {\n contextType: 'note',\n mergedContent: mergeNoteContent(content, { title: options.title, body: options.body }),\n existing: options.existing,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n\nexport async function resolveAndUpdateSavedQuery(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n name: string\n query: string\n connectionId?: string\n path?: string[]\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n const content = await resolveExistingContent(items, uid, 'saved_query', options.existing)\n return updateWithMergedContent(items, uid, {\n contextType: 'saved_query',\n mergedContent: mergeSavedQueryContent(content, options),\n existing: options.existing,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n\nexport async function resolveAndUpdateLink(\n items: ManagementContextItemsResource,\n uid: string,\n options: {\n title?: string\n url?: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n): Promise<ContextItem> {\n if (\n options.title === undefined &&\n options.url === undefined &&\n options.description === undefined &&\n options.userFeedback === undefined &&\n options.topics === undefined\n ) {\n throw new ValidationError('Provide at least one field to update.')\n }\n if (options.title === undefined && options.url === undefined) {\n return items.update(uid, {\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n }\n const content = await resolveExistingContent(items, uid, 'link', options.existing)\n return updateWithMergedContent(items, uid, {\n contextType: 'link',\n mergedContent: mergeLinkContent(content, { title: options.title, url: options.url }),\n existing: options.existing,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n })\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type {\n Dashboard,\n DashboardDraftSnapshot,\n DashboardVersion,\n} from '../../../../types/context-dashboards.js'\n\n/** Generated base for the management `context.dashboards` resource. */\nexport class ContextDashboardsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * Delete a dashboard.\n *\n * Removes the dashboard from every listing and deletes its alert workflows. It cannot be restored\n * through the API.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.delete('DASHBOARD_ID')\n * ```\n */\n async delete(dashboardId: string): Promise<void> {\n validateId(dashboardId, 'dashboardId')\n await invokeWithRetry(this.config, this.http, 'DashboardsController_delete', {\n pathParams: { dashboardId },\n })\n }\n\n /**\n * List dashboard draft snapshots.\n *\n * Returns ids and timestamps of the most recent draft snapshots. Editors only.\n *\n * **Requires:** `context:read`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')\n * snapshots.map((snapshot) => snapshot.uid)\n * ```\n */\n async listDraftSnapshots(dashboardId: string): Promise<DashboardDraftSnapshot[]> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_listDraftSnapshots', {\n pathParams: { dashboardId },\n })\n return asRecord(data).snapshots as DashboardDraftSnapshot[]\n }\n\n /**\n * Cancel an ownership transfer.\n *\n * Owner only. Clears the pending transfer and returns the dashboard.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')\n * ```\n */\n async cancelOwnershipTransfer(dashboardId: string): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_cancelOwnership', {\n pathParams: { dashboardId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n\n /**\n * Accept an ownership transfer.\n *\n * Recipient only. Makes you the owner and clears the pending transfer.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')\n * ```\n */\n async acceptOwnershipTransfer(dashboardId: string): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_acceptOwnership', {\n pathParams: { dashboardId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n\n /**\n * List dashboard versions.\n *\n * Returns the published versions, newest first, each with its full definition. Draft snapshots\n * are not included. The response is not paginated and can be large.\n *\n * **Requires:** `context:read`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n *\n * @example\n * ```ts\n * const versions = await mgmt.context.dashboards.listVersions('DASHBOARD_ID')\n * versions.map((version) => [version.uid, version.versionNumber])\n * ```\n */\n async listVersions(dashboardId: string): Promise<DashboardVersion[]> {\n validateId(dashboardId, 'dashboardId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_listVersions', {\n pathParams: { dashboardId },\n })\n return asRecord(data).versions as DashboardVersion[]\n }\n\n /**\n * Get a dashboard version.\n *\n * Returns the dashboard as it was in the given version. For a draft snapshot (editors only) the\n * view is reported as active and selectedVersion.versionNumber is null.\n *\n * **Requires:** `context:read`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n * @param versionId - Version id, or a draft snapshot id for editors.\n *\n * @example\n * ```ts\n * const old = await mgmt.context.dashboards.getVersion('DASHBOARD_ID', 'VERSION_ID')\n * old.selectedVersion.versionNumber\n * ```\n */\n async getVersion(\n dashboardId: string,\n versionId: string,\n ): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n validateId(versionId, 'versionId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_getVersion', {\n pathParams: { dashboardId, versionId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n\n /**\n * Restore a dashboard version.\n *\n * Replaces the current draft with the content of the given version. The outgoing draft is kept as\n * a draft snapshot. Returns the draft view.\n *\n * **Requires:** `context:write`\n *\n * @param dashboardId - Dashboard id, as shown in the app URL.\n * @param versionId - Version id, or a draft snapshot id for editors.\n *\n * @example\n * ```ts\n * await mgmt.context.dashboards.restoreVersion('DASHBOARD_ID', 'VERSION_ID')\n * ```\n */\n async restoreVersion(\n dashboardId: string,\n versionId: string,\n ): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n validateId(versionId, 'versionId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_restore', {\n pathParams: { dashboardId, versionId },\n })\n return asRecord(data) as unknown as Dashboard\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../../_config.js'\nimport type { HttpClient } from '../../../../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../../../../_request.js'\nimport { validateId } from '../../../../../_validation.js'\nimport type {\n DashboardElementResult,\n DashboardElementsList,\n} from '../../../../../types/context-dashboards.js'\n\n/** Generated base for the management `context.dashboards.elements` resource. */\nexport class ContextDashboardsElementsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly dashboardId: number | string,\n ) {}\n\n /**\n * List dashboard elements.\n *\n * Lists every tile and filter on the dashboard draft with id, kind, title and layout. Filters\n * also carry sqlReferences, the exact templates tile SQL must use to reference them. Returns the\n * current draftRevision.\n *\n * **Requires:** `context:read`\n *\n * @example\n * ```ts\n * const listed = await mgmt.context.dashboards.elements('DASHBOARD_ID').list()\n * listed.elements.map((element) => element.id)\n * ```\n */\n async list(): Promise<DashboardElementsList> {\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_listElements', {\n pathParams: { dashboardId: this.dashboardId },\n })\n return asRecord(data) as unknown as DashboardElementsList\n }\n\n /**\n * Get a dashboard element.\n *\n * Returns the full draft configuration of one dashboard element, including SQL, chart settings\n * and filter options, with the current draftRevision.\n *\n * **Requires:** `context:read`\n *\n * @param elementId - The dashboard element id to read.\n *\n * @example\n * ```ts\n * const result = await mgmt.context.dashboards.elements('DASHBOARD_ID').get('ELEMENT_ID')\n * result.element.title\n * ```\n */\n async get(elementId: string): Promise<DashboardElementResult> {\n validateId(elementId, 'elementId')\n const data = await invokeWithRetry(this.config, this.http, 'DashboardsController_getElement', {\n pathParams: { dashboardId: this.dashboardId, elementId },\n })\n return asRecord(data) as unknown as DashboardElementResult\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport { ContextDashboardsResourceBase } from '../../_generated/resources/management/context/dashboards.js'\nimport { ContextDashboardsElementsResourceBase } from '../../_generated/resources/management/context/dashboards/elements.js'\nimport type { HttpClient } from '../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type {\n CreateDashboardElementInput,\n CreateDashboardInput,\n Dashboard,\n DashboardElementResult,\n DashboardPublishResult,\n DashboardView,\n PublishDashboardInput,\n TransferDashboardOwnershipInput,\n UpdateDashboardAccessInput,\n UpdateDashboardDraftInput,\n UpdateDashboardElementInput,\n UpdateDashboardLayoutInput,\n} from '../../types/context-dashboards.js'\n\n/**\n * Tiles and filters on one dashboard draft.\n *\n * Call path: `mgmt.context.dashboards.elements(dashboardId)`.\n *\n * Every change takes the `draftRevision` it is based on as `expectedRevision`;\n * a stale value is rejected with a `ConflictError`.\n */\nexport class ManagementDashboardElementsResource extends ContextDashboardsElementsResourceBase {\n /** @internal */\n constructor(\n http: HttpClient,\n config: ModusConfig,\n dashboardId: string,\n ) {\n super(http, config, dashboardId)\n }\n\n /**\n * Add a blank tile or filter to the dashboard draft.\n *\n * Modus assigns the new element's id; configure it afterwards with `update()`.\n *\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.kind - `chart`, `kpi`, `table`, `markdown` or `filter`.\n * @param input.title - Title shown on the element.\n * @param input.layout - Grid position with `x` (0-11), `y`, `w` (1-12) and `h`.\n * @returns The created element and the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`; list the\n * elements again and retry with the new revision.\n * @example\n * ```ts\n * const created = await mgmt.context.dashboards.elements('DASHBOARD_ID').create({\n * expectedRevision: 3,\n * kind: 'chart',\n * title: 'Sales by region',\n * layout: { x: 0, y: 4, w: 6, h: 4 },\n * })\n * ```\n */\n async create(input: CreateDashboardElementInput): Promise<DashboardElementResult> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_createElement', {\n pathParams: { dashboardId: this.dashboardId },\n jsonBody: {\n expectedRevision: input.expectedRevision,\n kind: input.kind,\n title: input.title,\n layout: input.layout,\n },\n }),\n ) as unknown as DashboardElementResult\n }\n\n /**\n * Change settings of one tile or filter on the dashboard draft.\n *\n * @param elementId - Id of the tile or filter to change.\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.patch - The settings to change, for example `{ title: 'Sales' }`\n * or `{ defaultValue: null }`. `null` clears a setting that supports clearing.\n * @returns The whole dashboard after the change, including the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`.\n * @throws NotFoundError - The dashboard or the element does not exist, or you cannot\n * edit the dashboard.\n * @example\n * ```ts\n * const dashboard = await mgmt.context.dashboards\n * .elements('DASHBOARD_ID')\n * .update('ELEMENT_ID', { expectedRevision: 3, patch: { title: 'Revenue' } })\n * ```\n */\n async update(elementId: string, input: UpdateDashboardElementInput): Promise<Dashboard> {\n validateId(elementId, 'elementId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateElement', {\n pathParams: { dashboardId: this.dashboardId, elementId },\n jsonBody: { expectedRevision: input.expectedRevision, patch: input.patch },\n }),\n ) as unknown as Dashboard\n }\n}\n\n/**\n * Dashboards in the Modus knowledge base.\n *\n * Call path: `mgmt.context.dashboards` after `new ModusManagement(...)`.\n *\n * - `list()`, `get()`, `create()`, `updateDraft()`, `publish()`, `delete()` — dashboards.\n * - `listVersions()`, `getVersion()`, `restoreVersion()`, `listDraftSnapshots()` — history.\n * - `updateAccess()` — who can open and edit a dashboard.\n * - `requestOwnershipTransfer()`, `acceptOwnershipTransfer()`, `cancelOwnershipTransfer()`.\n * - `elements(dashboardId)` — list, get, create and update tiles and filters.\n * - `updateLayout(dashboardId, input)` — move or resize several elements at once.\n */\nexport class ManagementDashboardsResource extends ContextDashboardsResourceBase {\n /** @internal */\n constructor(\n http: HttpClient,\n config: ModusConfig,\n ) {\n super(http, config)\n }\n\n /**\n * List dashboards with their full definitions.\n *\n * @param options.view - `active` (default) lists published dashboards you can open;\n * `draft` lists the drafts of dashboards you can edit.\n * @returns Every matching dashboard. The list is not paginated.\n * @example\n * ```ts\n * const drafts = await mgmt.context.dashboards.list({ view: 'draft' })\n * drafts.map((dashboard) => [dashboard.id, dashboard.draftRevision])\n * ```\n */\n async list(options: { view?: DashboardView } = {}): Promise<Dashboard[]> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_list', {\n query: { view: options.view },\n }),\n )\n return data.dashboards as Dashboard[]\n }\n\n /**\n * Get one dashboard with its full definition.\n *\n * @param dashboardId - Id of the dashboard.\n * @param options.view - `active` (default) returns the published version; `draft`\n * returns the working draft and requires edit access.\n * @returns The dashboard, including `draftRevision` for the next change.\n * @throws NotFoundError - The dashboard does not exist or you cannot open it.\n * @example\n * ```ts\n * const draft = await mgmt.context.dashboards.get('DASHBOARD_ID', { view: 'draft' })\n * draft.draftRevision\n * ```\n */\n async get(dashboardId: string, options: { view?: DashboardView } = {}): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_get', {\n pathParams: { dashboardId },\n query: { view: options.view },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Create a dashboard draft.\n *\n * The new dashboard is not visible to others until you `publish()` it.\n *\n * @param input.title - Dashboard title.\n * @param input.definition - Tiles, filters and layout, for example\n * `{ tiles: [], filters: [] }`. Element ids must be unique.\n * @param input.description - Optional dashboard description.\n * @param input.access - Optional `visibility`, `groupPermissions` and `sharedWith`.\n * Defaults to private.\n * @returns The created dashboard in its draft view.\n * @throws ModusError - The definition or access settings are invalid.\n * @example\n * ```ts\n * const dashboard = await mgmt.context.dashboards.create({\n * title: 'Revenue',\n * definition: { tiles: [], filters: [] },\n * })\n * dashboard.id\n * ```\n */\n async create(input: CreateDashboardInput): Promise<Dashboard> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_create', {\n jsonBody: {\n title: input.title,\n description: input.description,\n definition: input.definition,\n access: input.access,\n },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Replace the whole draft definition, and optionally the title and description.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.definition - The complete new definition. Tiles and filters left\n * out are removed.\n * @param input.title - New title; unchanged when omitted.\n * @param input.description - New description; unchanged when omitted.\n * @returns The dashboard draft after the change, including the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`; get the draft\n * again and retry with the new revision.\n * @throws NotFoundError - The dashboard does not exist or you cannot edit it.\n * @example\n * ```ts\n * const draft = await mgmt.context.dashboards.get('DASHBOARD_ID', { view: 'draft' })\n * await mgmt.context.dashboards.updateDraft('DASHBOARD_ID', {\n * expectedRevision: draft.draftRevision,\n * definition: draft.definition,\n * title: 'Revenue',\n * })\n * ```\n */\n async updateDraft(dashboardId: string, input: UpdateDashboardDraftInput): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateDraft', {\n pathParams: { dashboardId },\n jsonBody: {\n expectedRevision: input.expectedRevision,\n title: input.title,\n description: input.description,\n definition: input.definition,\n },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Publish the draft as a new version that everyone with access sees.\n *\n * Alert workflows defined on the dashboard are updated to match.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.expectedRevision - The `draftRevision` you reviewed and want to publish.\n * @returns The published `dashboard` and the new `version`.\n * @throws ConflictError - The draft changed since `expectedRevision`.\n * @throws NotFoundError - The dashboard does not exist or you cannot edit it.\n * @example\n * ```ts\n * const result = await mgmt.context.dashboards.publish('DASHBOARD_ID', { expectedRevision: 4 })\n * result.version.versionNumber\n * ```\n */\n async publish(dashboardId: string, input: PublishDashboardInput): Promise<DashboardPublishResult> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_publish', {\n pathParams: { dashboardId },\n jsonBody: { expectedRevision: input.expectedRevision },\n }),\n ) as unknown as DashboardPublishResult\n }\n\n /**\n * Replace who can open and edit a dashboard.\n *\n * All three settings are required and replace the current ones.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.visibility - `shared` (the owner plus the groups in\n * `groupPermissions`) or `private` (the owner plus the users in `sharedWith`).\n * @param input.groupPermissions - Group id to `{ use, manage }`. Used only when shared.\n * @param input.sharedWith - Users such as `{ email: 'ana@example.com', permission: 'use' }`.\n * Used only when private.\n * @returns The dashboard with its new access settings.\n * @throws NotFoundError - The dashboard does not exist or you cannot edit it.\n * @throws ModusError - A group, user or permission is invalid.\n * @example\n * ```ts\n * await mgmt.context.dashboards.updateAccess('DASHBOARD_ID', {\n * visibility: 'private',\n * groupPermissions: {},\n * sharedWith: [{ email: 'ana@example.com', permission: 'use' }],\n * })\n * ```\n */\n async updateAccess(dashboardId: string, input: UpdateDashboardAccessInput): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateAccess', {\n pathParams: { dashboardId },\n jsonBody: {\n visibility: input.visibility,\n groupPermissions: input.groupPermissions,\n sharedWith: input.sharedWith,\n },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Ask another member of your organization to take ownership of a dashboard.\n *\n * Only the owner can request a transfer. Ownership moves when the recipient\n * calls `acceptOwnershipTransfer()`.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.newOwnerUserId - User id of the member who should become the owner.\n * @returns The dashboard with `pendingOwnershipTransfer` set.\n * @throws PermissionDeniedError - You are not the owner.\n * @throws NotFoundError - The dashboard does not exist or you cannot open it.\n * @example\n * ```ts\n * await mgmt.context.dashboards.requestOwnershipTransfer('DASHBOARD_ID', {\n * newOwnerUserId: 'USER_ID',\n * })\n * ```\n */\n async requestOwnershipTransfer(\n dashboardId: string,\n input: TransferDashboardOwnershipInput,\n ): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n validateId(input.newOwnerUserId, 'newOwnerUserId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_transferOwnership', {\n pathParams: { dashboardId },\n jsonBody: { newOwnerUserId: input.newOwnerUserId },\n }),\n ) as unknown as Dashboard\n }\n\n /**\n * Work with the tiles and filters of one dashboard draft.\n *\n * @param dashboardId - Id of the dashboard.\n * @returns A resource bound to that dashboard.\n * @example\n * ```ts\n * await mgmt.context.dashboards.elements('DASHBOARD_ID').list()\n * ```\n */\n elements(dashboardId: string): ManagementDashboardElementsResource {\n validateId(dashboardId, 'dashboardId')\n return new ManagementDashboardElementsResource(this.http, this.config, dashboardId)\n }\n\n /**\n * Move or resize several tiles and filters in one change.\n *\n * @param dashboardId - Id of the dashboard.\n * @param input.expectedRevision - The `draftRevision` your change is based on.\n * @param input.elements - Every element to place, each with `elementId` and its\n * final `layout`.\n * @returns The whole dashboard after the change, including the new `draftRevision`.\n * @throws ConflictError - The draft changed since `expectedRevision`.\n * @example\n * ```ts\n * await mgmt.context.dashboards.updateLayout('DASHBOARD_ID', {\n * expectedRevision: 3,\n * elements: [{ elementId: 'ELEMENT_ID', layout: { x: 0, y: 0, w: 12, h: 2 } }],\n * })\n * ```\n */\n async updateLayout(dashboardId: string, input: UpdateDashboardLayoutInput): Promise<Dashboard> {\n validateId(dashboardId, 'dashboardId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'DashboardsController_updateLayout', {\n pathParams: { dashboardId },\n jsonBody: { expectedRevision: input.expectedRevision, elements: input.elements },\n }),\n ) as unknown as Dashboard\n }\n}\n","import { readdir, readFile, stat } from 'node:fs/promises'\nimport { dirname, join, relative } from 'node:path'\nimport type { ModusConfig } from '../../_config.js'\nimport { ModusError, ValidationError } from '../../_exceptions.js'\nimport { ContextFilesResourceBase } from '../../_generated/resources/management/context/files.js'\nimport type { HttpClient } from '../../_http.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type {\n BulkFinalizeResult,\n BulkUploadFromUrlsResult,\n BulkUploadUrlsResult,\n FileUpload,\n FinalizeInput,\n UploadDirFailure,\n UploadDirResult,\n UploadFileInput,\n UploadFromUrlInput,\n UploadProgressCallback,\n UploadUrlInput,\n UploadUrlSlot,\n WaitUntil,\n} from '../../types/context-files.js'\n\n/** Bulk `createUploadUrls` / `uploadFromUrls` request cap — matches the backend. */\nexport const MAX_BULK_UPLOAD_FILES = 100\n\nconst DEFAULT_PUT_TIMEOUT_MS = 60_000\nconst DEFAULT_POLL_INTERVAL_MS = 500\nconst DEFAULT_UPLOAD_TIMEOUT_MS = 120_000\nconst DEFAULT_CONCURRENCY = 10\n// `pending` is gone from the public enum: an upload has no resource until it\n// is finalized. Kept at rank 0 so an older server still reporting it is\n// ordered below `processing` rather than treated as unknown.\nconst STATUS_ORDER: Record<string, number> = { pending: 0, processing: 1, ready: 2 }\nconst WAIT_UNTIL_VALUES = new Set<WaitUntil>(['processing', 'ready'])\n\n/**\n * The server owns the extension→MIME table (`EXTENSION_MIME_MAP` in\n * `@modus/file-uploads`) and resolves it whenever a client sends\n * `application/octet-stream`. Sending that instead of guessing locally keeps\n * one source of truth: a client-side table inevitably drifts from the server's\n * allow-list, and a guess the server rejects fails the upload for no reason.\n */\nconst DEFER_CONTENT_TYPE_TO_SERVER = 'application/octet-stream'\n\n/** A missing path (or one under a regular file, ENOTDIR) is bad caller input, so it throws ValidationError like a wrong file type does. */\nasync function statInput(path: string) {\n try {\n return await stat(path)\n } catch (error) {\n const code = (error as { code?: unknown }).code\n if (code === 'ENOENT' || code === 'ENOTDIR') throw new ValidationError(`No such file or directory: ${path}`)\n throw error\n }\n}\n\nfunction validateWaitUntil(waitUntil: string): asserts waitUntil is WaitUntil {\n if (!WAIT_UNTIL_VALUES.has(waitUntil as WaitUntil)) {\n throw new ValidationError(`waitUntil must be one of ${[...WAIT_UNTIL_VALUES].join(', ')}, got ${waitUntil}`)\n }\n}\n\nfunction validateBulkSize(count: number, name: string): void {\n if (count === 0) throw new ValidationError(`${name} must not be empty`)\n if (count > MAX_BULK_UPLOAD_FILES) {\n throw new ValidationError(`${name} must have at most ${MAX_BULK_UPLOAD_FILES} entries, got ${count}`)\n }\n}\n\nfunction statusSatisfies(status: string, waitUntil: WaitUntil): boolean {\n if (status === 'failed') return true\n return (STATUS_ORDER[status] ?? 0) >= STATUS_ORDER[waitUntil]\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\nfunction chunked<T>(items: readonly T[], size: number): T[][] {\n const out: T[][] = []\n for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size))\n return out\n}\n\n/** Join an optional destination prefix onto a walk-relative folder label. Empty prefix is a no-op. */\nfunction joinDestination(prefix: string | undefined, relative: string | undefined): string | undefined {\n const head = prefix === undefined || prefix.length === 0 ? undefined : prefix\n const tail =\n relative === undefined || relative.length === 0\n ? undefined\n : relative\n if (head !== undefined && tail !== undefined) return `${head}/${tail}`\n return head ?? tail\n}\n\nexport type BatchUploadOptions = {\n concurrency?: number\n waitUntil?: WaitUntil\n onProgress?: UploadProgressCallback\n folderPath?: string\n}\n\n/** Bounded-concurrency map, preserving input order — the async twin of a thread pool. */\nasync function mapWithConcurrency<T, R>(\n items: readonly T[],\n concurrency: number,\n worker: (item: T) => Promise<R>,\n onItemDone?: (result: R) => void,\n): Promise<R[]> {\n const results: R[] = new Array(items.length)\n let cursor = 0\n async function run(): Promise<void> {\n for (;;) {\n const index = cursor++\n if (index >= items.length) return\n const result = await worker(items[index] as T)\n results[index] = result\n onItemDone?.(result)\n }\n }\n await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, run))\n return results\n}\n\nasync function walkFiles(root: string, recursive: boolean): Promise<string[]> {\n const out: string[] = []\n async function walk(dir: string): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true })\n entries.sort((a, b) => a.name.localeCompare(b.name))\n for (const entry of entries) {\n if (entry.name.startsWith('.') || entry.isSymbolicLink()) continue\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n if (recursive) await walk(full)\n } else if (entry.isFile()) {\n out.push(full)\n }\n }\n }\n await walk(root)\n return out\n}\n\n// Servers released before `headers` existed omit it; their PUT needs only Content-Type.\ntype PutSlot = Pick<UploadUrlSlot, 'uploadUrl' | 'contentType'> & { headers?: Record<string, string> }\n\nasync function putBytes(fetchImpl: typeof fetch, slot: PutSlot, data: Uint8Array, timeoutMs: number): Promise<void> {\n const response = await fetchImpl(slot.uploadUrl, {\n method: 'PUT',\n body: data,\n headers: { 'Content-Type': slot.contentType, ...slot.headers },\n signal: AbortSignal.timeout(timeoutMs),\n })\n if (!response.ok) {\n const text = await response.text().catch(() => '')\n throw new ModusError(`Upload PUT to presigned URL failed with HTTP ${response.status}.`, {\n statusCode: response.status,\n body: text ? text.slice(0, 500) : undefined,\n })\n }\n}\n\nfunction createSlotsPayload(files: readonly UploadUrlInput[]): Record<string, unknown> {\n return {\n files: files.map((f) => ({ fileName: f.fileName, contentType: f.contentType, fileSize: f.fileSize })),\n }\n}\n\nfunction uploadFromUrlsPayload(urls: readonly UploadFromUrlInput[]): Record<string, unknown> {\n return {\n urls: urls.map((u) => ({\n url: u.url,\n ...(u.fileName !== undefined ? { fileName: u.fileName } : {}),\n ...(u.folderPath !== undefined ? { folderPath: u.folderPath } : {}),\n })),\n }\n}\n\ntype UploadPath = UploadFileInput\ntype SlotAssignment = UploadPath & { slot: UploadUrlSlot }\n\nfunction assignSlots(\n batch: readonly UploadPath[],\n result: BulkUploadUrlsResult,\n failed: UploadDirFailure[],\n): SlotAssignment[] {\n const failedIndices = new Set(result.failed.map((f) => f.index))\n for (const f of result.failed) {\n failed.push({ path: batch[f.index]?.path ?? '', error: f.error })\n }\n const remaining = batch.filter((_, i) => !failedIndices.has(i))\n const uploaded = result.uploaded\n if (uploaded.length < remaining.length) {\n for (const file of remaining.slice(uploaded.length)) {\n failed.push({ path: file.path, error: 'Server returned fewer upload slots than requested files.' })\n }\n }\n const paired = Math.min(remaining.length, uploaded.length)\n const assignments: SlotAssignment[] = []\n for (let i = 0; i < paired; i++) {\n assignments.push({ ...(remaining[i] as UploadPath), slot: uploaded[i] as UploadUrlSlot })\n }\n return assignments\n}\n\n/**\n * Durable file uploads for `ModusManagement`.\n *\n * Call path: `mgmt.context.files` after `new ModusManagement(...)`.\n *\n * - `upload(path)` / `uploadDir(dirPath)` — presign + PUT + poll convenience helpers.\n * - `createUploadUrl(s)`, `uploadFromUrl(s)`, `get`, `list` — raw operations.\n * Hierarchy browsing is available through `mgmt.context.items.list`.\n */\nexport class ManagementContextFilesResource extends ContextFilesResourceBase {\n /** @internal */\n constructor(\n http: HttpClient,\n config: ModusConfig,\n ) {\n super(http, config)\n }\n\n /**\n * Get a presigned S3 PUT URL for one file.\n *\n * @param input.fileName - Original file name — used to build the S3 object key.\n * @param input.contentType - MIME type. Allowed categories: PDF, images, text,\n * Office/OpenDocument documents, audio, and video.\n * @param input.fileSize - File size in bytes. Rejected above 50MB.\n * @returns Presigned upload slot. PUT the raw bytes to `uploadUrl` within 15\n * minutes, sending `headers` unchanged, then call `finalize(slot.uploadId, slot.fileName)`. Pass the\n * slot's own `fileName` rather than your local basename — the server may\n * sanitize the requested name when it mints the key, and finalization\n * re-derives the key from `uploadId` and `fileName`.\n */\n async createUploadUrl(input: UploadUrlInput): Promise<UploadUrlSlot> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadUrl', {\n jsonBody: { fileName: input.fileName, contentType: input.contentType, fileSize: input.fileSize },\n }),\n ) as unknown as UploadUrlSlot\n }\n\n /**\n * Get presigned S3 PUT URLs for up to 100 files in one call.\n *\n * @param files - Files to create upload slots for (max 100).\n * @returns Slots for every file that passed validation, plus per-index\n * failures (bad MIME type, oversize) for the rest — never a partial 4xx.\n */\n async createUploadUrls(files: readonly UploadUrlInput[]): Promise<BulkUploadUrlsResult> {\n validateBulkSize(files.length, 'files')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadUrls', {\n jsonBody: createSlotsPayload(files),\n }),\n ) as unknown as BulkUploadUrlsResult\n }\n\n /**\n * Fetch one file from a URL and land it as durable context.\n *\n * @param url - Source URL to fetch (SSRF-guarded, 50MB cap, same MIME\n * allow-list as `createUploadUrl`).\n * @param options.fileName - Override file name. Inferred from the URL path when omitted.\n * @param options.folderPath - Root-relative folder to upload under.\n * @returns File upload resource with status `processing` — parsing continues async.\n */\n async uploadFromUrl(url: string, options: { fileName?: string; folderPath?: string } = {}): Promise<FileUpload> {\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadFromUrl', {\n jsonBody: {\n url,\n ...(options.fileName !== undefined ? { fileName: options.fileName } : {}),\n ...(options.folderPath !== undefined ? { folderPath: options.folderPath } : {}),\n },\n }),\n ) as unknown as FileUpload\n }\n\n /**\n * Fetch up to 100 files from URLs in one call.\n *\n * @param urls - URLs to fetch and upload (max 100).\n * @returns File upload resources for every URL that landed, plus per-index\n * failures for the rest — never a partial 4xx.\n */\n async uploadFromUrls(urls: readonly UploadFromUrlInput[]): Promise<BulkUploadFromUrlsResult> {\n validateBulkSize(urls.length, 'urls')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_uploadFromUrls', {\n jsonBody: uploadFromUrlsPayload(urls),\n }),\n ) as unknown as BulkUploadFromUrlsResult\n }\n\n /**\n * Turn a file already PUT to a presigned URL into durable context.\n *\n * Call this once the PUT completes. The server locates the object from\n * `uploadId` + `fileName` and validates the bytes that actually arrived.\n * Safe to retry — a second call returns the same resource.\n *\n * @param uploadId - Upload id returned by `createUploadUrl`.\n * @param fileName - File name returned alongside it.\n * @returns The file upload resource, status `\"processing\"`.\n */\n async finalize(uploadId: string, fileName: string, options: { folderPath?: string } = {}): Promise<FileUpload> {\n validateId(uploadId, 'uploadId')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_finalize', {\n pathParams: { uploadId },\n jsonBody: { fileName, ...(options.folderPath !== undefined ? { folderPath: options.folderPath } : {}) },\n }),\n ) as unknown as FileUpload\n }\n\n /**\n * Finalize up to 100 uploads in one call.\n *\n * What makes directory upload cheap: 2000 files cost 20 requests here rather\n * than 2000.\n *\n * @param uploads - Uploads to finalize (max 100).\n * @returns Resources for every upload that finalized, plus per-index\n * failures for the rest — never a partial 4xx.\n */\n async finalizeMany(uploads: readonly FinalizeInput[]): Promise<BulkFinalizeResult> {\n validateBulkSize(uploads.length, 'uploads')\n return asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_finalizeMany', {\n jsonBody: {\n uploads: uploads.map((u) => ({\n uploadId: u.uploadId,\n fileName: u.fileName,\n ...(u.folderPath !== undefined ? { folderPath: u.folderPath } : {}),\n })),\n },\n }),\n ) as unknown as BulkFinalizeResult\n }\n\n /**\n * Upload an explicit list of local files.\n *\n * Same machinery as `uploadDir`, without the directory walk — use it when\n * the caller already knows which files to send.\n *\n * @param paths - Paths to local files.\n * @param options.concurrency - Max concurrent PUTs (default 10).\n * @param options.waitUntil - `\"processing\"` (default) or `\"ready\"`.\n * @param options.onProgress - Optional progress callback after each file.\n * @param options.folderPath - Root-relative folder to upload under. Nested\n * files keep their existing relative folder labels under this prefix.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const result = await mgmt.context.files.uploadFiles(\n * ['./q3.pdf', './notes.md'],\n * { folderPath: 'reports/2026' },\n * )\n * ```\n */\n async uploadFiles(\n paths: readonly (string | UploadFileInput)[],\n options: BatchUploadOptions = {},\n ): Promise<UploadDirResult> {\n return this.uploadPaths(paths.map((input) => typeof input === 'string' ? { path: input } : input), options)\n }\n\n /**\n * Upload a local file and wait for it to reach `\"processing\"` or `\"ready\"`.\n *\n * Gets a presigned URL, PUTs the file bytes, then polls `get()`\n * until the upload leaves `\"pending\"` (or reaches `\"ready\"`/`\"failed\"`).\n *\n * @param path - Path to a local file.\n * @param options.waitUntil - `\"processing\"` (parsing started, default) or\n * `\"ready\"` (parsing finished).\n * @param options.pollIntervalMs - Milliseconds between status polls.\n * @param options.timeoutMs - Max milliseconds to wait before raising.\n * @param options.folderPath - Root-relative folder to upload under. Example:\n * `{ folderPath: 'reports/2026' }` places `./report.pdf` at `reports/2026`.\n * @returns The file upload resource once it reaches `waitUntil` (or `\"failed\"`).\n * @throws {ModusError} If the PUT fails, or polling times out.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const file = await mgmt.context.files.upload('./report.pdf', { folderPath: 'reports/2026' })\n * ```\n */\n async upload(\n path: string,\n options: {\n waitUntil?: WaitUntil\n pollIntervalMs?: number\n timeoutMs?: number\n folderPath?: string\n } = {},\n ): Promise<FileUpload> {\n const waitUntil = options.waitUntil ?? 'processing'\n validateWaitUntil(waitUntil)\n const fileStat = await statInput(path)\n if (!fileStat.isFile()) throw new ValidationError(`Not a file: ${path}`)\n const fileName = path.split(/[/\\\\]/).pop() as string\n const slot = await this.createUploadUrl({\n fileName,\n contentType: DEFER_CONTENT_TYPE_TO_SERVER,\n fileSize: fileStat.size,\n })\n const data = await readFile(path)\n await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS)\n // Finalize returns the resource already at `processing`, so it replaces the\n // first poll rather than adding a round trip. Only `waitUntil: 'ready'`\n // needs to keep polling afterwards.\n const finalized = await this.finalize(slot.uploadId, slot.fileName, {\n ...(options.folderPath !== undefined ? { folderPath: options.folderPath } : {}),\n })\n if (statusSatisfies(finalized.status, waitUntil)) return finalized\n return this.pollUntil(\n slot.uploadId,\n waitUntil,\n options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS,\n options.timeoutMs ?? DEFAULT_UPLOAD_TIMEOUT_MS,\n )\n }\n\n private async pollUntil(\n uploadId: string,\n waitUntil: WaitUntil,\n pollIntervalMs: number,\n timeoutMs: number,\n ): Promise<FileUpload> {\n const deadline = Date.now() + timeoutMs\n for (;;) {\n const item = await this.get(uploadId)\n if (statusSatisfies(item.status, waitUntil)) return item\n if (Date.now() >= deadline) {\n throw new ModusError(\n `Timed out after ${timeoutMs}ms waiting for upload ${JSON.stringify(uploadId)} to reach ` +\n `status ${JSON.stringify(waitUntil)}; last status was ${JSON.stringify(item.status)}.`,\n )\n }\n await sleep(pollIntervalMs)\n }\n }\n\n /**\n * Upload every file in a local directory.\n *\n * Walks `path` (skipping hidden files/directories and symlinks), pages\n * through `createUploadUrls()` in batches of up to 100, then PUTs and polls\n * each file with up to `concurrency` in flight at once. A failure on one\n * file does not stop the others — check `result.failed`.\n *\n * @param path - Path to a local directory.\n * @param options.recursive - Recurse into subdirectories (default `true`).\n * @param options.concurrency - Max concurrent PUT+poll operations (default 10).\n * @param options.waitUntil - `\"processing\"` (default) or `\"ready\"` — same as `upload()`.\n * @param options.onProgress - Optional progress callback after each file.\n * @param options.folderPath - Root-relative folder to upload under. Nested\n * files keep their path relative to `path` under this prefix. Example:\n * `uploadDir('./docs', { folderPath: 'reports' })` places `./docs/a.txt` at\n * `reports` and `./docs/nested/b.txt` at `reports/nested`.\n * @returns `UploadDirResult` with every successful `FileUpload` and every\n * per-file failure (slot creation or PUT/poll), each tagged with its local path.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const result = await mgmt.context.files.uploadDir('./docs', { folderPath: 'reports' })\n * ```\n */\n async uploadDir(\n path: string,\n options: {\n recursive?: boolean\n concurrency?: number\n waitUntil?: WaitUntil\n onProgress?: UploadProgressCallback\n folderPath?: string\n } = {},\n ): Promise<UploadDirResult> {\n const waitUntil = options.waitUntil ?? 'processing'\n validateWaitUntil(waitUntil)\n const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY\n if (concurrency < 1) throw new ValidationError(`concurrency must be >= 1, got ${concurrency}`)\n const dirStat = await statInput(path)\n if (!dirStat.isDirectory()) throw new ValidationError(`Not a directory: ${path}`)\n\n const files = await walkFiles(path, options.recursive ?? true)\n return this.uploadPaths(files.map((file) => {\n const folderPath = relative(path, dirname(file)).replace(/\\\\/g, '/')\n return { path: file, ...(folderPath.length > 0 ? { folderPath } : {}) }\n }), options)\n }\n\n /** Shared body of `uploadFiles` and `uploadDir`: presign in batches of 100,\n * PUT with bounded concurrency, then bulk-finalize the batch. */\n private async uploadPaths(\n files: readonly UploadPath[],\n options: BatchUploadOptions,\n ): Promise<UploadDirResult> {\n const waitUntil = options.waitUntil ?? 'processing'\n validateWaitUntil(waitUntil)\n const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY\n if (concurrency < 1) throw new ValidationError(`concurrency must be >= 1, got ${concurrency}`)\n\n const prefixed = files.map((file) => {\n const folderPath = joinDestination(options.folderPath, file.folderPath)\n return { path: file.path, ...(folderPath !== undefined ? { folderPath } : {}) }\n })\n\n const uploaded: FileUpload[] = []\n const failed: UploadDirFailure[] = []\n const total = files.length\n let completed = 0\n const emit = () => {\n completed += 1\n options.onProgress?.({\n completed,\n total,\n succeeded: uploaded.length,\n failed: failed.length,\n })\n }\n\n for (const batch of chunked(prefixed, MAX_BULK_UPLOAD_FILES)) {\n const failedBefore = failed.length\n const slots = await this.createSlots(batch, failed)\n // createSlots can report several failures from one synchronous call, so tick\n // `failed` up one at a time here — reusing `emit()` would report the final\n // `failed.length` on every tick and break the completed = succeeded + failed\n // invariant for all but the last of them.\n for (let reported = failedBefore + 1; reported <= failed.length; reported += 1) {\n completed += 1\n options.onProgress?.({ completed, total, succeeded: uploaded.length, failed: reported })\n }\n await this.uploadBatch(slots, waitUntil, concurrency, (result) => {\n if ('error' in result) failed.push(result)\n else uploaded.push(result)\n emit()\n })\n }\n return { uploaded, failed }\n }\n\n private async createSlots(batch: readonly UploadPath[], failed: UploadDirFailure[]): Promise<SlotAssignment[]> {\n const readable: UploadPath[] = []\n const inputs: UploadUrlInput[] = []\n for (const file of batch) {\n try {\n const fileStat = await stat(file.path)\n const fileName = file.path.split(/[/\\\\]/).pop() as string\n inputs.push({ fileName, contentType: DEFER_CONTENT_TYPE_TO_SERVER, fileSize: fileStat.size })\n readable.push(file)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n failed.push({ path: file.path, error: message })\n }\n }\n if (inputs.length === 0) return []\n const result = await this.createUploadUrls(inputs)\n return assignSlots(readable, result, failed)\n }\n\n private async uploadBatch(\n slots: readonly SlotAssignment[],\n waitUntil: WaitUntil,\n concurrency: number,\n onOutcome?: (result: FileUpload | UploadDirFailure) => void,\n ): Promise<(FileUpload | UploadDirFailure)[]> {\n if (slots.length === 0) return []\n const out: (FileUpload | UploadDirFailure)[] = []\n\n // PUT everything first, collecting the ones whose bytes landed.\n type PutOutcome = { landed: SlotAssignment } | { failure: UploadDirFailure }\n const put = await mapWithConcurrency<SlotAssignment, PutOutcome>(\n slots,\n concurrency,\n async ({ path, folderPath, slot }) => {\n try {\n const data = await readFile(path)\n await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS)\n return { landed: { path, ...(folderPath !== undefined ? { folderPath } : {}), slot } }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n return { failure: { path, error: message } }\n }\n },\n (outcome) => {\n // Emit PUT failures as each concurrent worker finishes — do not wait for\n // the rest of the batch / finalize before progress moves.\n if ('failure' in outcome) {\n out.push(outcome.failure)\n onOutcome?.(outcome.failure)\n }\n },\n )\n const landed: SlotAssignment[] = []\n for (const entry of put) {\n if ('failure' in entry) {\n // already recorded + emitted in onItemDone\n continue\n }\n landed.push(entry.landed)\n }\n if (landed.length === 0) return out\n\n // One bulk finalize for the whole batch — the reason a 2000-file directory\n // costs 20 requests here instead of 2000.\n const result = await this.finalizeMany(\n landed.map(({ slot, folderPath }) => ({\n uploadId: slot.uploadId,\n fileName: slot.fileName,\n ...(folderPath !== undefined ? { folderPath } : {}),\n })),\n )\n const failedIndices = new Set(result.failed.map((f) => f.index))\n for (const f of result.failed) {\n const failure: UploadDirFailure = { path: landed[f.index]?.path ?? '', error: f.error }\n out.push(failure)\n onOutcome?.(failure)\n }\n const finalized = result.finalized\n const remaining = landed.filter((_, i) => !failedIndices.has(i))\n\n if (waitUntil !== 'ready') {\n for (const item of finalized) {\n out.push(item)\n onOutcome?.(item)\n }\n return out\n }\n\n // Only `ready` needs polling; `processing` is already satisfied by the\n // finalize response.\n await mapWithConcurrency(\n remaining,\n concurrency,\n async ({ path, slot }) => {\n try {\n return await this.pollUntil(slot.uploadId, waitUntil, DEFAULT_POLL_INTERVAL_MS, DEFAULT_UPLOAD_TIMEOUT_MS)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n return { path, error: message } satisfies UploadDirFailure\n }\n },\n (item) => {\n out.push(item)\n onOutcome?.(item)\n },\n )\n return out\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../../../_request.js'\nimport { validateId, validatePageSize } from '../../../../_validation.js'\nimport type { FileUpload } from '../../../../types/context-files.js'\n\n/** Generated base for the management `context.files` resource. */\nexport class ContextFilesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List file uploads.\n *\n * Returns a page of durable landed file uploads. Uploads that have not landed yet are visible via\n * `GET /context/files/{uploadId}`, not this list.\n *\n * **Requires:** `context:read`\n *\n * @param options.pageSize - Items per page. Defaults to 50.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @returns A page of files.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<FileUpload>> {\n const pageSize = options.pageSize ?? 50\n validatePageSize(pageSize, 200)\n return this.listPage(pageSize, options.pageToken)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<FileUpload>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextFilesController_list', {\n query: aipListParams(pageSize, pageToken) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'files',\n (raw) => raw as FileUpload,\n (token) => this.listPage(pageSize, token),\n )\n }\n\n /**\n * Get a file upload.\n *\n * Returns status + metadata for one upload. Prefers the durable landed context item; falls back\n * to in-flight upload status while the object has not landed yet. 404 if neither exists.\n *\n * **Requires:** `context:read`\n *\n * @param uploadId - Upload id returned by `createUploadUrl` / `createUploadUrls`.\n */\n async get(uploadId: string): Promise<FileUpload> {\n validateId(uploadId, 'uploadId')\n const data = await invokeWithRetry(this.config, this.http, 'ContextFilesController_get', {\n pathParams: { uploadId },\n })\n return asRecord(data) as unknown as FileUpload\n }\n}\n","import type { OperationId } from '../../_generated/operations.js'\nimport type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { aipListParams, buildAipPage, type Page } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { ValidationError } from '../../_exceptions.js'\nimport { validatePageSize } from '../../_validation.js'\nimport type {\n ContextItem,\n ContextItemAccessUpdate,\n ContextItemDeletion,\n ContextItemMove,\n UpdateContextItemAccessInput,\n} from '../../types/context.js'\nimport type { UserFeedback } from './_content-merge.js'\n\nfunction contextListParams(\n pageSize: number,\n pageToken: string | undefined,\n filters: ListContextItemsFilters = {},\n): Record<string, string | number | boolean | readonly string[] | undefined | null> {\n const extra: Record<string, string | readonly string[]> = {}\n if (filters.contextType !== undefined) extra.contextTypes = [filters.contextType]\n if (filters.parentUids !== undefined) {\n extra.parentUids = filters.parentUids.length === 0 ? '' : [...filters.parentUids]\n }\n if (filters.ancestorUids !== undefined) {\n extra.ancestorUids = filters.ancestorUids.length === 0 ? '' : [...filters.ancestorUids]\n }\n if (filters.connectionIds !== undefined) {\n extra.connectionIds = filters.connectionIds.length === 0 ? '' : [...filters.connectionIds]\n }\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | readonly string[] | undefined | null\n >\n}\n\ntype ListContextItemsFilters = {\n contextType?: string\n parentUids?: readonly string[]\n ancestorUids?: readonly string[]\n connectionIds?: readonly string[]\n}\n\n/** The move request body; a caller sending both destinations gets an error instead of one being dropped. */\nfunction moveBody(options: { destinationFolderUid?: string | null; destinationFolderPath?: string }): Record<string, unknown> {\n if (options.destinationFolderPath === undefined) return { destinationFolderUid: options.destinationFolderUid }\n if (options.destinationFolderUid !== undefined) {\n throw new ValidationError('Pass destinationFolderUid or destinationFolderPath, not both')\n }\n return { destinationFolderPath: options.destinationFolderPath }\n}\n\nfunction parseContextItem(raw: unknown): ContextItem {\n return raw as ContextItem\n}\n\nexport class ManagementContextItemsResource {\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List context items in the knowledge base.\n *\n * @param options.pageSize - Items per page (default 25).\n * @param options.pageToken - Token from a previous page's `nextPageToken`.\n * @param options.contextType - Filter to one context type (for example `\"note\"`).\n * @param options.parentUids - Exact ordered native ancestry chain for direct\n * children. Omit to leave parent unrestricted; pass `[]` for the known-empty\n * root. Native UIDs are exact tokens; for a folder's children send ancestry\n * UIDs plus the last `dataPath` token, not the hashed context-item `uid`.\n * @param options.ancestorUids - Ordered UID ancestry prefix for strict\n * descendants. Omit to leave unrestricted; pass `[]` for every item with\n * non-null ancestry.\n * @param options.connectionIds - Restrict to these connection ids. Omit to\n * leave unfiltered; pass `[]` to match none. The Files root is\n * `connectionIds: ['files']` with `parentUids: []`.\n * @returns A page of context items.\n *\n * @example\n * ```ts\n * const rootFiles = await mgmt.context.items.list({\n * connectionIds: ['files'],\n * contextType: 'file_upload',\n * parentUids: [],\n * })\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n contextType?: string\n parentUids?: readonly string[]\n ancestorUids?: readonly string[]\n connectionIds?: readonly string[]\n } = {}): Promise<Page<ContextItem>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, {\n contextType: options.contextType,\n parentUids: options.parentUids,\n ancestorUids: options.ancestorUids,\n connectionIds: options.connectionIds,\n })\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n filters: ListContextItemsFilters,\n ): Promise<Page<ContextItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_list', {\n query: contextListParams(pageSize, pageToken, filters),\n }),\n )\n return buildAipPage(data, 'contextItems', parseContextItem, (token) =>\n this.listPage(pageSize, token, filters),\n )\n }\n\n /**\n * Retrieve one context item by uid.\n *\n * @param uid - Context item uid.\n * @returns The context item.\n */\n async get(uid: string): Promise<ContextItem> {\n const data = await invokeWithRetry(this.config, this.http, 'ContextItemsController_get', {\n pathParams: { uid },\n })\n return parseContextItem(data)\n }\n\n /**\n * Update a context item.\n *\n * Only the fields you pass are changed. To clear a field, name it in\n * `updateMask` and leave its argument unset: it is sent as `null`.\n *\n * @param uid - Context item uid.\n * @param options.content - Replacement type-specific content.\n * @param options.contextType - Item type (for example `\"note\"`). Required when `content` is supplied.\n * @param options.description - New description.\n * @param options.userFeedback - Feedback verdict: `\"positive\"`, `\"neutral\"`, or `\"negative\"`.\n * @param options.topics - Replacement topic tags. Pass `[]` to clear all tags.\n * @param options.updateMask - Comma-separated field names to update or clear.\n * @returns The updated context item.\n */\n async update(\n uid: string,\n options: {\n content?: unknown\n contextType?: string\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n updateMask?: string\n } = {},\n ): Promise<ContextItem> {\n const body = updateBody({\n content: options.content,\n contextType: options.contextType,\n description: options.description,\n userFeedback: options.userFeedback,\n topics: options.topics,\n }, options.updateMask)\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_update', {\n pathParams: { uid },\n query: updateMaskQuery(options.updateMask),\n jsonBody: body,\n })\n return this.get(uid)\n }\n\n /**\n * Delete a context item. Deleting a Files folder also deletes all its contents.\n *\n * @param uid - Context item uid.\n * @returns Deletion confirmation details.\n */\n async delete(uid: string): Promise<ContextItemDeletion> {\n const data = await invokeWithRetry(this.config, this.http, 'ContextItemsController_delete', {\n pathParams: { uid },\n })\n return data as ContextItemDeletion\n }\n\n /**\n * Move a live file or Files folder.\n *\n * Pass exactly one destination: `destinationFolderUid` (an existing folder,\n * or `null` for the Files root), or `destinationFolderPath` (a root-relative\n * path such as `reports/2026`; missing folders on it are created with the\n * move). Same-parent moves succeed as a no-op. Does not rename or merge folders.\n *\n * @param uid - Stored context-item uid of the file or folder to move.\n * @param options.destinationFolderUid - Stored context-item uid of the\n * destination folder, or `null` for the Files root.\n * @param options.destinationFolderPath - Root-relative destination folder path.\n * @returns How many items changed parent (`0` is a successful no-op).\n * @throws {NotFoundError} The source is missing or not visible.\n * @throws {ModusError} The destination is missing, not a Files folder, or\n * the move would create a cycle (HTTP 400).\n * @throws {PermissionDeniedError} The destination exists but is not writable\n * for this caller.\n * @throws {ConflictError} A sibling with the same name already exists.\n *\n * @example\n * ```ts\n * const moved = await mgmt.context.items.move('PLACEHOLDER_UID', {\n * destinationFolderUid: 'PLACEHOLDER_FOLDER_UID',\n * })\n * console.log(moved.movedItems)\n * ```\n */\n async move(\n uid: string,\n options:\n | { destinationFolderUid: string | null; destinationFolderPath?: never }\n | { destinationFolderPath: string; destinationFolderUid?: never },\n ): Promise<ContextItemMove> {\n const data = await invokeWithRetry(\n this.config,\n this.http,\n 'ContextItemsController_move' as OperationId,\n {\n pathParams: { uid },\n jsonBody: moveBody(options),\n },\n )\n return data as ContextItemMove\n }\n\n /**\n * Replace who can view and manage a note, saved query, link or uploaded file.\n *\n * All three settings are required and replace the current ones. You cannot\n * remove your own manage access. An item created before items had owners\n * becomes yours on the first change.\n *\n * @param uid - UUID of the context item.\n * @param input.visibility - `shared` (the owner plus the groups in\n * `groupPermissions`) or `private` (the owner plus the users in `sharedWith`).\n * @param input.groupPermissions - Group id to `{ use, manage }`. Used only when shared.\n * @param input.sharedWith - Users such as `{ email: 'ana@example.com', permission: 'use' }`.\n * Used only when private.\n * @returns The item's new access settings and whether you can still manage it.\n * @throws {NotFoundError} The item does not exist or you cannot view it.\n * @throws {PermissionDeniedError} You can view the item but not manage it.\n * @throws {ModusError} The item is another type, a group or user is invalid,\n * or the change would remove your own manage access.\n *\n * @example\n * ```ts\n * await mgmt.context.items.updateAccess('PLACEHOLDER_UID', {\n * visibility: 'private',\n * groupPermissions: {},\n * sharedWith: [{ email: 'ana@example.com', permission: 'use' }],\n * })\n * ```\n */\n async updateAccess(\n uid: string,\n input: UpdateContextItemAccessInput,\n ): Promise<ContextItemAccessUpdate> {\n const data = await invokeWithRetry(\n this.config,\n this.http,\n 'ContextItemAccessController_updateAccess' as OperationId,\n {\n pathParams: { uid },\n jsonBody: {\n visibility: input.visibility,\n groupPermissions: input.groupPermissions,\n sharedWith: input.sharedWith,\n },\n },\n )\n return data as ContextItemAccessUpdate\n }\n}\n","import type { OperationId } from '../../_generated/operations.js'\nimport type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport type { ContextItem, CreatedContextItem } from '../../types/context.js'\nimport { withCreatedUid } from '../../types/context.js'\nimport { CustomContextItemsResource } from '../../resources/context/custom-items.js'\nimport {\n resolveAndUpdateLink,\n resolveAndUpdateNote,\n resolveAndUpdateSavedQuery,\n type UserFeedback,\n} from './_content-merge.js'\nimport { ManagementDashboardsResource } from './dashboards.js'\nimport { ManagementContextFilesResource } from './files.js'\nimport { ManagementContextItemsResource } from './items.js'\n\n/**\n * Create and update context items (notes, links, saved queries, file uploads).\n *\n * Call path: `mgmt.context` after `new ModusManagement(...)`.\n */\nexport class ManagementContextResource {\n readonly items: ManagementContextItemsResource\n readonly customItems: CustomContextItemsResource\n readonly files: ManagementContextFilesResource\n readonly dashboards: ManagementDashboardsResource\n\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {\n this.items = new ManagementContextItemsResource(http, config)\n this.customItems = new CustomContextItemsResource(http, config)\n this.files = new ManagementContextFilesResource(http, config)\n this.dashboards = new ManagementDashboardsResource(http, config)\n }\n\n /**\n * Add a free-form text note to the knowledge base.\n *\n * @param title - Note title.\n * @param content - Note body (markdown).\n * @returns The created context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const note = await mgmt.context.createNote('Runbook', '# Steps\\n1. Check logs')\n * ```\n */\n createNote(title: string, content: string): Promise<CreatedContextItem> {\n return this.create('ContextCreatorsController_createNote', omitUndefined({ title, content }))\n }\n\n /**\n * Update a note's title and markdown body.\n *\n * Preserves server-owned fields on the existing content blob. Pass `existing`\n * to skip a fetch when you already have the item from a list call.\n *\n * @param uid - Context item uid.\n * @param options.title - New title.\n * @param options.body - New markdown body.\n * @param options.existing - Optional cached item to avoid a GET.\n * @returns The updated context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const item = await mgmt.context.updateNote('PLACEHOLDER_UID', {\n * title: 'Runbook',\n * body: '# Steps\\n1. Check logs\\n2. Escalate',\n * })\n * ```\n */\n updateNote(\n uid: string,\n options: {\n title: string\n body: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n ): Promise<ContextItem> {\n return resolveAndUpdateNote(this.items, uid, options)\n }\n\n /**\n * Save a SQL query to the knowledge base.\n *\n * @param name - Display name for the query.\n * @param options.connectionId - Connection the query runs against.\n * @param options.query - SQL text.\n * @param options.path - Optional hierarchy path segments.\n * @returns The created context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const query = await mgmt.context.createSavedQuery('Monthly ARR', {\n * connectionId: 'conn_warehouse',\n * query: 'select * from arr_monthly',\n * })\n * ```\n */\n createSavedQuery(\n name: string,\n options: {\n query?: string\n connectionId: string\n description?: string\n path?: string[]\n },\n ): Promise<CreatedContextItem> {\n return this.create(\n 'ContextCreatorsController_createSavedQuery',\n omitUndefined({\n name,\n query: options.query,\n connectionId: options.connectionId,\n description: options.description,\n path: options.path,\n }),\n )\n }\n\n /**\n * Update a saved query's name, SQL, and optional connection metadata.\n *\n * @param uid - Context item uid.\n * @param options.name - New display name.\n * @param options.query - New SQL text.\n * @param options.existing - Optional cached item to avoid a GET.\n * @returns The updated context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const item = await mgmt.context.updateSavedQuery('PLACEHOLDER_UID', {\n * name: 'Monthly ARR',\n * query: 'select sum(amount) from arr_monthly',\n * })\n * ```\n */\n updateSavedQuery(\n uid: string,\n options: {\n name: string\n query: string\n connectionId?: string\n path?: string[]\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n ): Promise<ContextItem> {\n return resolveAndUpdateSavedQuery(this.items, uid, options)\n }\n\n /**\n * Add a URL to the knowledge base.\n *\n * @param url - Link URL.\n * @param options.title - Optional display title.\n * @param options.isCrawl - When true, crawl linked pages into context.\n * @param options.pageLimit - Maximum pages to crawl when `isCrawl` is true.\n * @returns The created context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const link = await mgmt.context.createLink('https://docs.example.com/runbook', {\n * title: 'Ops runbook',\n * })\n * ```\n */\n createLink(\n url: string,\n options: { title?: string; isCrawl?: boolean; pageLimit?: number } = {},\n ): Promise<CreatedContextItem> {\n return this.create(\n 'ContextCreatorsController_createLink',\n omitUndefined({\n url,\n title: options.title,\n isCrawl: options.isCrawl,\n pageLimit: options.pageLimit,\n }),\n )\n }\n\n /**\n * Update link metadata on an existing item.\n *\n * Merges `title` and/or `url` into the stored content blob. Does not re-fetch or re-crawl the URL.\n *\n * @param uid - Context item uid.\n * @param options.title - New display title.\n * @param options.url - New URL.\n * @param options.existing - Optional cached item to avoid a GET.\n * @returns The updated context item.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const item = await mgmt.context.updateLink('PLACEHOLDER_UID', {\n * title: 'Ops runbook (2025)',\n * })\n * ```\n */\n updateLink(\n uid: string,\n options: {\n title?: string\n url?: string\n existing?: ContextItem\n description?: string\n userFeedback?: UserFeedback\n topics?: string[]\n },\n ): Promise<ContextItem> {\n return resolveAndUpdateLink(this.items, uid, options)\n }\n\n /** @internal */\n private async create(operationId: OperationId, payload: Record<string, unknown>): Promise<CreatedContextItem> {\n const data = await invokeWithRetry(this.config, this.http, operationId, {\n jsonBody: payload,\n })\n return withCreatedUid(data as Parameters<typeof withCreatedUid>[0])\n }\n}\n\nexport type { UserFeedback } from './_content-merge.js'\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../../_request.js'\nimport { validateId, validatePageSize } from '../../../_validation.js'\nimport type {\n McpExposureCatalog,\n McpExposureCatalogRequest,\n} from '../../../management/scopes/mcp-exposure-catalog.js'\nimport type { Scope } from '../../../types/scopes.js'\nimport type { VariationView } from '../../../types/views.js'\n\n/** Generated base for the management `scopes` resource. */\nexport class ScopesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List scopes.\n *\n * Returns a paginated page of scopes the caller can at least `use`. Scopes the caller cannot see\n * are filtered out. Pagination uses an opaque token returned in `nextPageToken`.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @param options.search - Case-insensitive substring filter on scope name.\n * @param options.view - Variation view. `active` reads the deployed version, or the latest draft\n * when nothing is published. `draft` reads the latest builder snapshot. `published` reads only\n * the published version, and only scopes you can use.\n * @param options.managerId - Return only scopes supervised by this manager scope id.\n * @returns A page of scopes.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {\n * console.log(scope.id, scope.name, scope.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n view?: VariationView\n managerId?: number\n } = {}): Promise<Page<Scope>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.search, options.view, options.managerId)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n view?: VariationView,\n managerId?: number,\n ): Promise<Page<Scope>> {\n const extra: Record<string, string | number> = {}\n if (search !== undefined) extra.search = search\n if (view !== undefined) extra.view = view\n if (managerId !== undefined) extra.managerId = managerId\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ScopesController_list', {\n query: aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'scopes',\n (raw) => raw as Scope,\n (token) => this.listPage(pageSize, token, search, view, managerId),\n )\n }\n\n /**\n * Get a scope.\n *\n * Returns a scope. `view=active` (default) is the deployed version, or the latest draft when\n * nothing is published. `view=draft` is the latest edits. `view=published` is only the published\n * version, and only if you can use the scope. Returns 404 if you cannot access it.\n *\n * **Requires:** `scopes:read`\n *\n * @param scopeId - Numeric scope id.\n * @param options.view - Which version to read. Defaults to `active`. `published` is only the\n * published version, and only if you can use the scope.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')\n * console.log(scope.name, scope.status)\n * ```\n */\n async get(\n scopeId: number | string,\n options: { view?: VariationView } = {},\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_get', {\n pathParams: { id: scopeId },\n query: { view: options.view },\n })\n return data as Scope\n }\n\n /**\n * Delete a scope.\n *\n * Deletes a scope. The scope can be restored later with POST /scopes/{id}/restore. Returns 404 if\n * the scope does not exist or is already deleted.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n *\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')\n * ```\n */\n async delete(scopeId: number | string): Promise<void> {\n validateId(scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, 'ScopesController_delete', {\n pathParams: { id: scopeId },\n })\n }\n\n /**\n * Preview MCP exposure catalog.\n *\n * Lists tools this scope can expose to MCP clients. A field you send replaces the current draft;\n * a field you omit stays as stored. Nothing is saved. Entries you cannot access are left out, and\n * stored selections on them are counted in hiddenSelectedCount.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n * @param request - Request body; see `McpExposureCatalogRequest`.\n *\n * @example\n * ```ts\n * const catalog = await mgmt.scopes.mcpExposureCatalog(42, {})\n * catalog.discoveryAllowed\n * ```\n */\n async mcpExposureCatalog(\n scopeId: number | string,\n request: McpExposureCatalogRequest,\n ): Promise<McpExposureCatalog> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_mcpExposureCatalog', {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined(request as Record<string, unknown>),\n })\n return data as McpExposureCatalog\n }\n\n /**\n * Restore a deleted scope.\n *\n * Restores a previously deleted scope and returns it. Restoring a scope that is already active\n * returns it unchanged.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n */\n async restore(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_restore', {\n pathParams: { id: scopeId },\n jsonBody: {},\n })\n return data as Scope\n }\n\n /**\n * Cancel ownership transfer.\n *\n * Cancels a pending ownership transfer. The current owner may cancel, the pending recipient may\n * decline, and for a scope with no owner an organization owner may cancel.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n */\n async cancelOwnershipTransfer(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_cancelOwnershipTransfer', {\n pathParams: { id: scopeId },\n })\n return data as Scope\n }\n\n /**\n * Accept ownership transfer.\n *\n * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.\n *\n * **Requires:** `scopes:write`\n *\n * @param scopeId - Numeric scope id.\n */\n async acceptOwnershipTransfer(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_acceptOwnershipTransfer', {\n pathParams: { id: scopeId },\n jsonBody: {},\n })\n return data as Scope\n }\n}\n","const EVERYONE_GROUP_ID = '__everyone__'\n\nexport function accessConfigWireForCreate(guardrails: string[]): Record<string, unknown> {\n return {\n visibility: 'shared',\n groupPermissions: { [EVERYONE_GROUP_ID]: { use: true, manage: true } },\n guardrails,\n sharedWith: [],\n }\n}\n\nexport function accessConfigWireForUpdate(\n existing: Record<string, unknown> | undefined,\n guardrails: string[],\n): Record<string, unknown> {\n if (!existing || Object.keys(existing).length === 0) {\n return accessConfigWireForCreate(guardrails)\n }\n return { ...existing, guardrails }\n}\n\nexport function accessFromSkillResponse(raw: Record<string, unknown>): Record<string, unknown> {\n const value = raw.accessConfig ?? raw.access_config\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n return value as Record<string, unknown>\n }\n return {}\n}\n\nexport function accessConfigBodyForCreate(\n guardrails?: string[],\n): Record<string, unknown> | undefined {\n if (guardrails === undefined) return undefined\n return accessConfigWireForCreate(guardrails)\n}\n\nexport async function accessConfigBodyForUpdate(\n guardrails: string[] | undefined,\n loadResource: () => Promise<Record<string, unknown>>,\n): Promise<Record<string, unknown> | undefined> {\n if (guardrails === undefined) return undefined\n const existing = accessFromSkillResponse(await loadResource())\n return accessConfigWireForUpdate(existing, guardrails)\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../../_pagination.js'\nimport { updateMaskQuery } from '../../../../_query.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../../../_request.js'\nimport { validateId, validatePageSize } from '../../../../_validation.js'\nimport type {\n Memory,\n MemorySearchRequest,\n MemorySearchResult,\n MemoryUpdate,\n} from '../../../../management/types/memories.js'\n\n/** Generated base for the management `scopes.memories` resource. */\nexport class ScopesMemoriesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * List scope memories.\n *\n * Returns a page of the scope’s memories (up to 1000 total). Pass `nextPageToken` as `pageToken`\n * to fetch the next page. Optional `userId` filters to one end user.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @param options.userId - Narrow results to memories tagged with this end-user id.\n * @returns A page of memories.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n userId?: string\n } = {}): Promise<Page<Memory>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.userId)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n userId?: string,\n ): Promise<Page<Memory>> {\n validateId(this.scopeId, 'scope_id')\n const extra: Record<string, string> = {}\n if (userId !== undefined) extra.userId = userId\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_list', {\n pathParams: { id: this.scopeId },\n query: aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'memories',\n (raw) => raw as Memory,\n (token) => this.listPage(pageSize, token, userId),\n )\n }\n\n /**\n * Search scope memories.\n *\n * Returns memories ranked by semantic similarity to the supplied `query`. Caller must at least\n * `use` the scope. Optional `userId` and `limit` body fields narrow the result set (legacy parity\n * with `search-memories`).\n *\n * **Requires:** `scopes:read`\n *\n * @param request - Request body; see `MemorySearchRequest`.\n */\n async search(request: MemorySearchRequest): Promise<MemorySearchResult> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_search', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined(request as Record<string, unknown>),\n })\n return data as MemorySearchResult\n }\n\n /**\n * Update a memory.\n *\n * Updates one memory. Supply at least one of `memory` or `metadata`. Use `updateMask` to limit\n * which fields change.\n *\n * **Requires:** `scopes:write`\n *\n * @param memoryId - Opaque memory id as returned by the list / search endpoints.\n * @param update - Request body; see `MemoryUpdate`.\n * @param options.updateMask - Comma-separated list of fields to update. Omit to update all\n * provided fields.\n */\n async update(\n memoryId: string,\n update: MemoryUpdate,\n options: { updateMask?: string } = {},\n ): Promise<void> {\n validateId(memoryId, 'memory_id')\n validateId(this.scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_update', {\n pathParams: { id: this.scopeId, memoryId },\n query: updateMaskQuery(options.updateMask),\n jsonBody: omitUndefined(update as Record<string, unknown>),\n })\n }\n\n /**\n * Delete a memory.\n *\n * Deletes one memory. Returns 404 if the memory does not exist or is already deleted.\n *\n * **Requires:** `scopes:write`\n *\n * @param memoryId - Opaque memory id as returned by the list / search endpoints.\n */\n async delete(memoryId: string): Promise<void> {\n validateId(memoryId, 'memory_id')\n validateId(this.scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, 'ScopeMemoriesController_delete', {\n pathParams: { id: this.scopeId, memoryId },\n })\n }\n}\n","import { ScopesMemoriesResourceBase } from '../../_generated/resources/management/scopes/memories.js'\n\n/** Long-term memory stored per scope. */\nexport class ScopeMemoriesResource extends ScopesMemoriesResourceBase {}\n","import { randomUUID } from 'node:crypto'\nimport { ScopesEvaluationsResourceBase } from '../../_generated/resources/management/scopes/evaluations.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { AddEvaluationCase, EvaluationCase, UpdateEvaluationCase } from '../types/evaluations.js'\n\n/** Scheduled and manual scope evaluations. */\nexport class ScopeEvaluationsResource extends ScopesEvaluationsResourceBase {\n /**\n * Add one evaluation case and return the stored case.\n *\n * @param input.task - What the scope should do. An empty string is allowed.\n * @param input.expectedOutput - What a correct result looks like. An empty string is allowed.\n * @param input.id - Stable id. Omit it and the client assigns one before the request, so a retry sends the same id.\n * @returns The stored evaluation case, including its id.\n * @throws ConflictError An evaluation case with this id already exists. A retry after the case was stored returns this error. An identical body is not treated as success.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const added = await mgmt.scopes.evaluations(42).addCase({\n * task: \"Summarize last quarter's revenue\",\n * expectedOutput: 'A one-paragraph summary with the total',\n * })\n * console.log(added.id)\n * ```\n */\n async addCase(input: AddEvaluationCase): Promise<EvaluationCase> {\n validateId(this.scopeId, 'scope_id')\n const id = input.id ?? randomUUID()\n validateId(id, 'id')\n return await invokeWithRetry(this.config, this.http, 'ScopesController_addEvaluationCase', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined({ ...input, id }),\n }) as EvaluationCase\n }\n\n /**\n * Change the task, the expected output, or both, for one evaluation case.\n *\n * @param caseId - Id of the case to change.\n * @param patch.task - Replacement task. Omit to leave it unchanged.\n * @param patch.expectedOutput - Replacement expected output. Omit to leave it unchanged.\n * @returns The evaluation case after the change.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const updated = await mgmt.scopes.evaluations(42).updateCase('CASE_ID', {\n * task: 'Summarize revenue in two sentences',\n * })\n * console.log(updated.task)\n * ```\n */\n async updateCase(caseId: string, patch: UpdateEvaluationCase): Promise<EvaluationCase> {\n validateId(this.scopeId, 'scope_id')\n validateId(caseId, 'case_id')\n return await invokeWithRetry(this.config, this.http, 'ScopesController_updateEvaluationCase', {\n pathParams: { id: this.scopeId, caseId },\n jsonBody: omitUndefined(patch),\n }) as EvaluationCase\n }\n\n /**\n * Remove one evaluation case. The other cases stay as they are.\n *\n * @param caseId - Id of the case to remove.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * await mgmt.scopes.evaluations(42).deleteCase('CASE_ID')\n * ```\n */\n async deleteCase(caseId: string): Promise<void> {\n validateId(this.scopeId, 'scope_id')\n validateId(caseId, 'case_id')\n await invokeWithRetry(this.config, this.http, 'ScopesController_deleteEvaluationCase', {\n pathParams: { id: this.scopeId, caseId },\n })\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../../../_request.js'\nimport { validateId, validatePageSize } from '../../../../_validation.js'\nimport type {\n EvaluationConfig,\n EvaluationRun,\n EvaluationRunWithResults,\n TriggerEvaluationRunResponse,\n UpdateEvaluationConfig,\n} from '../../../../management/types/evaluations.js'\n\n/** Generated base for the management `scopes.evaluations` resource. */\nexport class ScopesEvaluationsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * Get evaluation configuration.\n *\n * Returns the evaluation configuration for a scope, including judge settings, schedule cadence,\n * and notification preferences.\n *\n * **Requires:** `scopes:read`\n */\n async getConfig(): Promise<EvaluationConfig> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_getConfig', {\n pathParams: { id: this.scopeId },\n })\n return data as EvaluationConfig\n }\n\n /**\n * Update evaluation configuration.\n *\n * Updates the evaluation configuration for a scope. Changes to the schedule cadence are synced\n * automatically.\n *\n * **Requires:** `scopes:write`\n *\n * @param update - Request body; see `UpdateEvaluationConfig`.\n */\n async updateConfig(update: UpdateEvaluationConfig): Promise<EvaluationConfig> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_updateConfig', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined(update as Record<string, unknown>),\n })\n return data as EvaluationConfig\n }\n\n /**\n * Trigger evaluation run.\n *\n * Triggers a manual evaluation run for the scope. The run executes asynchronously.\n *\n * **Requires:** `scopes:write`\n *\n * @returns Evaluation run accepted and queued. The run executes asynchronously; poll `GET\n * /scopes/{id}/evaluations/runs/{runId}` for status.\n */\n async triggerRun(): Promise<TriggerEvaluationRunResponse> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_triggerRun', {\n pathParams: { id: this.scopeId },\n })\n return data as TriggerEvaluationRunResponse\n }\n\n /**\n * List evaluation runs.\n *\n * Returns a paginated list of evaluation runs for the scope, ordered by most recent first.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @returns A page of runs.\n */\n listRuns(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<EvaluationRun>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listRunsPage(pageSize, options.pageToken)\n }\n\n protected async listRunsPage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<EvaluationRun>> {\n validateId(this.scopeId, 'scope_id')\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'EvaluationsController_listRuns', {\n pathParams: { id: this.scopeId },\n query: aipListParams(pageSize, pageToken) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'runs',\n (raw) => raw as EvaluationRun,\n (token) => this.listRunsPage(pageSize, token),\n )\n }\n\n /**\n * Get evaluation run.\n *\n * Returns details of an evaluation run including all per-case results.\n *\n * **Requires:** `scopes:read`\n *\n * @param runId - Run ID.\n */\n async getRun(runId: string): Promise<EvaluationRunWithResults> {\n validateId(this.scopeId, 'scope_id')\n validateId(runId, 'run_id')\n const data = await invokeWithRetry(this.config, this.http, 'EvaluationsController_getRun', {\n pathParams: { id: this.scopeId, runId },\n })\n return data as EvaluationRunWithResults\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type { ScopeInterface } from '../../../../management/scopes/interfaces.js'\n\n/** Generated base for the management `scopes.interfaces` resource. */\nexport class ScopesInterfacesResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * List the chat interfaces of a scope.\n *\n * Returns the chat interfaces (at most one per chat platform) that let people use this scope from\n * chat. Requires manage permission on the scope, because the config lists allowed emails.\n *\n * **Requires:** `scopes:read`\n */\n async list(): Promise<ScopeInterface[]> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_list', {\n pathParams: { id: this.scopeId },\n })\n return (data as { interfaces: ScopeInterface[] }).interfaces\n }\n\n /**\n * Remove a scope interface.\n *\n * Removes one chat interface from the scope. Mentions on that chat platform stop reaching this\n * scope immediately.\n *\n * **Requires:** `scopes:write`\n *\n * @param interfaceId - Interface id (UUID).\n */\n async delete(interfaceId: string): Promise<void> {\n validateId(this.scopeId, 'scope_id')\n validateId(interfaceId, 'interface_id')\n await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_delete', {\n pathParams: { id: this.scopeId, interfaceId },\n })\n }\n}\n","import { ScopesInterfacesResourceBase } from '../../_generated/resources/management/scopes/interfaces.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport type { components } from '../../_generated/v1.js'\n\nexport type ScopeInterface = components['schemas']['ScopeInterfaceDto']\nexport type AddScopeInterface = components['schemas']['AddScopeInterfaceDto']\nexport type UpdateScopeInterface = components['schemas']['UpdateScopeInterfaceDto']\n\nexport class ScopeInterfacesResource extends ScopesInterfacesResourceBase {\n\n /**\n * Add a Slack or Microsoft Teams interface to this scope.\n *\n * @param options - Interface type, optional name and config.\n * @returns The created interface.\n */\n async create(options: AddScopeInterface): Promise<ScopeInterface> {\n validateId(this.scopeId, 'scope_id')\n return await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_add', {\n pathParams: { id: this.scopeId },\n jsonBody: omitUndefined(options),\n }) as ScopeInterface\n }\n\n /**\n * Update an interface on this scope.\n *\n * @param interfaceId - Interface id.\n * @param options - Updated name and/or config.\n * @param updateMask - Optional comma-separated field names to update.\n * @returns The updated interface.\n */\n async update(interfaceId: string, options: UpdateScopeInterface, updateMask?: string): Promise<ScopeInterface> {\n validateId(this.scopeId, 'scope_id')\n validateId(interfaceId, 'interface_id')\n return await invokeWithRetry(this.config, this.http, 'ScopeInterfacesController_update', {\n pathParams: { id: this.scopeId, interfaceId },\n query: updateMaskQuery(updateMask),\n jsonBody: updateBody(options, updateMask),\n }) as ScopeInterface\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../../_config.js'\nimport type { HttpClient } from '../../../../_http.js'\nimport { invokeWithRetry } from '../../../../_request.js'\nimport { validateId } from '../../../../_validation.js'\nimport type {\n SetSupervisionRequest,\n Supervision,\n} from '../../../../management/scopes/supervision.js'\nimport type { SupervisionView } from '../../../../types/views.js'\n\n/** Generated base for the management `scopes.supervision` resource. */\nexport class ScopesSupervisionResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n protected readonly scopeId: number | string,\n ) {}\n\n /**\n * Read the scope subordinate supervision list.\n *\n * Returns the list of subordinate scope ids managed by this scope. `?view=active` (default) reads\n * the deployed supervision set; `?view=draft` reads the most recent builder snapshot. Returns 404\n * when the caller cannot at least `use` the scope.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.view - Which variation snapshot to read. Defaults to `active`.\n */\n async get(options: { view?: SupervisionView } = {}): Promise<Supervision> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeSupervisionController_get', {\n pathParams: { id: this.scopeId },\n query: { view: options.view },\n })\n return data as Supervision\n }\n\n /**\n * Replace draft subordinate supervision list.\n *\n * Writes the supplied subordinate id list into the draft variation. Replaces the previous list\n * fully — supply an empty array to clear all subordinates. Requires manage permission on the\n * supervisor; the change is not visible to runners until the scope is deployed.\n *\n * **Requires:** `scopes:write`\n *\n * @param request - Request body; see `SetSupervisionRequest`.\n */\n async set(request: SetSupervisionRequest): Promise<Supervision> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeSupervisionController_set', {\n pathParams: { id: this.scopeId },\n jsonBody: request,\n })\n return data as Supervision\n }\n\n /**\n * Replace active subordinate supervision list.\n *\n * Writes directly into the active variation supervision set, bypassing the draft deploy cycle.\n * Requires `scopes:write` plus manage permission on the supervisor. Use to correct a live\n * supervision graph without going through the builder.\n *\n * **Requires:** `scopes:write`\n *\n * @param request - Request body; see `SetSupervisionRequest`.\n */\n async setActive(request: SetSupervisionRequest): Promise<Supervision> {\n validateId(this.scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeSupervisionController_setActive', {\n pathParams: { id: this.scopeId },\n jsonBody: request,\n })\n return data as Supervision\n }\n}\n","import { ScopesSupervisionResourceBase } from '../../_generated/resources/management/scopes/supervision.js'\nimport type { components } from '../../_generated/v1.js'\n\nexport type Supervision = components['schemas']['SupervisionDto']\nexport type SetSupervisionRequest = components['schemas']['SetSupervisionRequestDto']\n\nexport class ScopeSupervisionResource extends ScopesSupervisionResourceBase {}\n","import { ScopesResourceBase } from '../../_generated/resources/management/scopes.js'\nimport type { OperationId } from '../../_generated/operations.js'\nimport { updateBody, updateMaskQuery } from '../../_query.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { validateId } from '../../_validation.js'\nimport { ScopeConversationsResource } from '../../resources/scopes/conversations.js'\nimport type { Scope } from '../../types/scopes.js'\nimport {\n accessConfigBodyForCreate,\n accessConfigBodyForUpdate,\n} from '../_access-config.js'\nimport type { components } from '../../_generated/v1.js'\nimport type { JsonObjectListInput } from '../types/json-blob.js'\nimport type { ToolsetInput } from '../types/toolset.js'\nimport { ScopeMemoriesResource } from './memories.js'\nimport { ScopeEvaluationsResource } from './evaluations.js'\nimport { ScopeInterfacesResource } from './interfaces.js'\nimport { ScopeSupervisionResource } from './supervision.js'\n\n/** The canonical `/api/v1/scopes` management operationIds. */\ninterface ManagementScopesOperations {\n readonly list: OperationId\n readonly get: OperationId\n readonly create: OperationId\n readonly update: OperationId\n readonly deploy: OperationId\n readonly applySelectionOps: OperationId\n readonly delete: OperationId\n readonly restore: OperationId\n readonly requestOwnershipTransfer: OperationId\n readonly cancelOwnershipTransfer: OperationId\n readonly acceptOwnershipTransfer: OperationId\n readonly patchMcpConfig: OperationId\n readonly getVariation: OperationId\n}\n\n/** A connectionSet row from `scopes.get`, or a plain `{ connection_id, preferences }` object. */\ntype ConnectionSetRowInput = components['schemas']['ConnectionSetItemDto']\n\nconst MANAGEMENT_SCOPE_OPERATIONS: ManagementScopesOperations = {\n list: 'ScopesController_list',\n get: 'ScopesController_get',\n create: 'ScopesController_create',\n update: 'ScopesController_update',\n deploy: 'ScopesController_deploy',\n applySelectionOps: 'ScopesController_applySelectionOps',\n delete: 'ScopesController_delete',\n restore: 'ScopesController_restore',\n requestOwnershipTransfer: 'ScopesController_requestOwnershipTransfer',\n cancelOwnershipTransfer: 'ScopesController_cancelOwnershipTransfer',\n acceptOwnershipTransfer: 'ScopesController_acceptOwnershipTransfer',\n patchMcpConfig: 'ScopesController_patchMcpConfig',\n getVariation: 'ScopesController_getVariation',\n}\n\nfunction parseScope(raw: unknown): Scope {\n return raw as Scope\n}\n\nexport interface CreateScopeOptions {\n name: string\n description?: string\n expectedOutput?: string\n instructions?: string[]\n toolset?: ToolsetInput\n model?: string\n connectionSet?: ReadonlyArray<ConnectionSetRowInput>\n contextSelections?: JsonObjectListInput\n includeOwnLearnings?: boolean\n includeOrgLearnings?: boolean\n interfaces?: JsonObjectListInput\n guardrails?: string[]\n}\n\n/** @deprecated Use `CreateScopeOptions` instead. */\nexport type CreateSkillOptions = CreateScopeOptions\n\nexport interface UpdateScopeOptions {\n name?: string\n description?: string\n expectedOutput?: string\n instructions?: string[]\n toolset?: ToolsetInput\n model?: string\n connectionSet?: ReadonlyArray<ConnectionSetRowInput>\n contextSelections?: JsonObjectListInput\n interfaces?: JsonObjectListInput\n guardrails?: string[]\n /** Numeric id of the manager scope, or `null` to detach from the current manager. */\n managerId?: number | null\n evaluations?: JsonObjectListInput\n supervisionSubordinateDescriptions?: Record<string, string>\n updateMask?: string\n}\n\n/** @deprecated Use `UpdateScopeOptions` instead. */\nexport type UpdateSkillOptions = UpdateScopeOptions\n\n/**\n * Full CRUD and lifecycle for Modus scopes.\n *\n * Call path: `mgmt.scopes` after `new ModusManagement(...)`.\n */\nexport class ManagementScopesResource extends ScopesResourceBase {\n protected readonly ops: ManagementScopesOperations = MANAGEMENT_SCOPE_OPERATIONS\n\n /**\n * Conversations for a scope.\n *\n * @param scopeId - Scope id.\n * @returns A conversations resource scoped to the scope.\n */\n conversations(scopeId: number | string): ScopeConversationsResource {\n return new ScopeConversationsResource(this.http, this.config, scopeId)\n }\n\n /**\n * Long-term memories for a scope.\n *\n * @param scopeId - Scope id.\n * @returns A memories resource scoped to the scope.\n */\n memories(scopeId: number | string): ScopeMemoriesResource {\n return new ScopeMemoriesResource(this.http, this.config, scopeId)\n }\n\n /**\n * Evaluations for a scope.\n *\n * @param scopeId - Scope id.\n * @returns An evaluations resource scoped to the scope.\n */\n evaluations(scopeId: number | string): ScopeEvaluationsResource {\n return new ScopeEvaluationsResource(this.http, this.config, scopeId)\n }\n\n /**\n * Supervision (subordinate scopes) for a scope.\n *\n * @param scopeId - Scope id.\n * @returns A supervision resource scoped to the scope.\n */\n supervision(scopeId: number | string): ScopeSupervisionResource {\n return new ScopeSupervisionResource(this.http, this.config, scopeId)\n }\n\n /**\n * Slack and Microsoft Teams interfaces for a scope.\n *\n * @param scopeId - Scope id.\n * @returns An interfaces resource scoped to the scope.\n */\n interfaces(scopeId: number | string): ScopeInterfacesResource {\n return new ScopeInterfacesResource(this.http, this.config, scopeId)\n }\n\n /**\n * Create a new scope in the organization.\n *\n * @param options.name - Display name for the scope.\n * @param options.description - Optional description.\n * @param options.instructions - Optional system instructions.\n * @param options.model - Optional model id.\n * @param options.toolset - Optional tool selection for the scope.\n * @param options.includeOwnLearnings - Whether the scope reads what is taught while using it. Defaults to true.\n * @param options.includeOrgLearnings - Whether create adds the org-wide learnings path (`auto_generated:org`) to the scope's selections. Defaults to true; not applied when `contextSelections` already mention learnings or are context filters without a rule-based query. `false` only skips that addition: selections that already name the path still read org-wide learnings.\n * @param options.guardrails - Runtime guardrail labels (for example `\"no-pii\"`). Omit to create with no guardrails.\n * @returns The created scope (draft).\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.create({ name: 'Support assistant', model: 'claude-sonnet-5' })\n * console.log(scope.id, scope.name)\n * ```\n */\n async create(options: CreateScopeOptions): Promise<Scope> {\n const body = omitUndefined({\n name: options.name,\n description: options.description,\n expectedOutput: options.expectedOutput,\n instructions: options.instructions,\n toolset: options.toolset,\n model: options.model,\n connectionSet: options.connectionSet,\n contextSelections: options.contextSelections,\n includeOwnLearnings: options.includeOwnLearnings,\n includeOrgLearnings: options.includeOrgLearnings,\n interfaces: options.interfaces,\n accessConfig: accessConfigBodyForCreate(options.guardrails),\n })\n const data = await invokeWithRetry(this.config, this.http, this.ops.create, {\n jsonBody: body,\n })\n return parseScope(data)\n }\n\n /**\n * Update a scope's configuration.\n *\n * Only the fields you pass are changed. To clear a field, name it in\n * `updateMask` (comma-separated field names) and leave its argument unset:\n * it is sent as `null`.\n *\n * @param scopeId - Numeric scope id.\n * @param options.guardrails - Guardrail labels to set. Fetches the current scope first to merge. Pass `[]` to clear all.\n * @param options.managerId - Numeric id of the manager scope to move this scope under, or `null`\n * to detach it. Send it alone: the server rejects it combined with other fields.\n * @param options.updateMask - Comma-separated field names to update or clear.\n * @returns The updated scope.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.update('PLACEHOLDER_SCOPE_ID', {\n * description: 'Answers billing questions for enterprise customers.',\n * })\n * ```\n */\n async update(scopeId: number | string, options: UpdateScopeOptions = {}): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const accessConfig = await accessConfigBodyForUpdate(options.guardrails, async () =>\n asRecord(\n await invokeWithRetry(this.config, this.http, this.ops.get, {\n pathParams: { id: scopeId },\n }),\n ),\n )\n const fields = {\n name: options.name,\n description: options.description,\n expectedOutput: options.expectedOutput,\n instructions: options.instructions,\n toolset: options.toolset,\n model: options.model,\n connectionSet: options.connectionSet,\n contextSelections: options.contextSelections,\n interfaces: options.interfaces,\n accessConfig,\n managerId: options.managerId,\n evaluations: options.evaluations,\n supervisionSubordinateDescriptions: options.supervisionSubordinateDescriptions,\n }\n const body = updateBody(fields, options.updateMask)\n const data = await invokeWithRetry(this.config, this.http, this.ops.update, {\n pathParams: { id: scopeId },\n query: updateMaskQuery(options.updateMask),\n jsonBody: body,\n })\n return parseScope(data)\n }\n\n /**\n * Publish the current draft of a scope.\n *\n * @param scopeId - Scope id.\n * @returns The published scope.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const scope = await mgmt.scopes.create({ name: 'Support assistant' })\n * const published = await mgmt.scopes.deploy(scope.id)\n * console.log(published.status)\n * ```\n */\n async deploy(scopeId: number | string): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, this.ops.deploy, {\n pathParams: { id: scopeId },\n jsonBody: {},\n }),\n )\n return parseScope(data.scope)\n }\n\n /**\n * Apply selection changes to a scope.\n *\n * Pass `validateOnly: true` to run the same checks and return the scope that would\n * be saved, without writing. Set a connection with `setConnectionPreferences` and\n * remove it with `removeConnection`.\n *\n * @param scopeId - Scope id.\n * @param ops - Selection changes, applied in order.\n * @param options.toolset - The scope toolset after the edit, when the edit changed it.\n * @param options.validateOnly - When true, check and return the planned scope without writing.\n * @returns The scope, or the scope that would be saved when `validateOnly` is true.\n * @example\n * ```ts\n * const mgmt = new ModusManagement()\n * const preview = await mgmt.scopes.applySelectionOps(42, [{\n * op: 'setConnectionPreferences',\n * connectionId: '11111111-1111-4111-8111-111111111111',\n * preferences: { schemaVersion: 2, mode: 'all', include: [], exclude: [] },\n * }], { validateOnly: true })\n * console.log(preview.id)\n * ```\n */\n async applySelectionOps(\n scopeId: number | string,\n ops: ReadonlyArray<Record<string, unknown>>,\n options?: { toolset?: Record<string, unknown>; validateOnly?: boolean },\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, this.ops.applySelectionOps, {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({\n ops,\n toolset: options?.toolset,\n validateOnly: options?.validateOnly ? true : undefined,\n }),\n })\n return parseScope(data)\n }\n\n /**\n * Start transferring ownership of a scope to another organization member.\n *\n * The current owner calls this, and the recipient accepts. A scope with no owner (one\n * created with a service-account token) can be given one by an organization owner;\n * assigning yourself takes effect at once.\n *\n * @param scopeId - Scope id.\n * @param options.newOwnerUserId - User id of the proposed new owner.\n * @returns The scope with a pending ownership transfer.\n */\n async requestOwnershipTransfer(\n scopeId: number | string,\n options: { newOwnerUserId: string },\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(\n this.config,\n this.http,\n this.ops.requestOwnershipTransfer,\n {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({ newOwnerUserId: options.newOwnerUserId }),\n },\n )\n return parseScope(data)\n }\n\n /**\n * Update MCP server configuration for a scope.\n *\n * @param scopeId - Scope id.\n * @param options.mcpConfig - MCP configuration object.\n */\n async patchMcpConfig(\n scopeId: number | string,\n options: { mcpConfig: Record<string, unknown> },\n ): Promise<void> {\n validateId(scopeId, 'scope_id')\n await invokeWithRetry(this.config, this.http, this.ops.patchMcpConfig, {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({ config: options.mcpConfig }),\n })\n }\n\n /**\n * Retrieve a specific scope variation by uid.\n *\n * @param scopeId - Scope id.\n * @param options.variationUid - Variation uid.\n * @returns The scope variation.\n */\n async getVariation(\n scopeId: number | string,\n options: { variationUid: string },\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n validateId(options.variationUid, 'variation_uid')\n const data = await invokeWithRetry(this.config, this.http, this.ops.getVariation, {\n pathParams: { id: scopeId, variationUid: options.variationUid },\n })\n return parseScope(data)\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { invokeWithRetry } from '../../../_request.js'\nimport type { UsageUsersReport } from '../../../types/usage.js'\n\n/** Generated base for the management `usage` resource. */\nexport class UsageResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List usage users.\n *\n * Returns the distinct acting-user emails that appear in your organization's LLM usage over the\n * `[since, until)` window. Feeds the usage page's user filter (includes non-Modus Slack/Teams\n * users). Scoped to your organization.\n *\n * **Requires:** `usage:read`\n *\n * @param options.since - ISO8601 start of the query window (inclusive).\n * @param options.until - ISO8601 end of the query window (exclusive).\n */\n async listUsers(options: { since: string; until: string }): Promise<UsageUsersReport> {\n const data = await invokeWithRetry(this.config, this.http, 'UsageController_listUsers', {\n query: { since: options.since, until: options.until },\n })\n return data as UsageUsersReport\n }\n}\n","import { UsageResourceBase } from '../_generated/resources/management/usage.js'\nimport { invokeWithRetry } from '../_request.js'\nimport type { UsageReport, UsageRollup } from '../types/usage.js'\n\nexport class ManagementUsageResource extends UsageResourceBase {\n /**\n * List usage metrics for your organization over a time window.\n *\n * @param options.since - Start of the window (ISO 8601, inclusive).\n * @param options.until - End of the window (ISO 8601, exclusive).\n * @param options.rollup - Bucket size for each row: `\"hour\"` or `\"day\"`.\n * @param options.model - Optional filter to a single model name.\n * @param options.userEmail - Optional filter to one or more acting-user emails.\n * @returns Usage report rows for the window.\n * @throws {UnprocessableError} When the request is rejected by the API.\n * @throws {AuthenticationError} When the API key is invalid or missing.\n */\n async list(options: {\n since: string\n until: string\n rollup: UsageRollup\n model?: string\n userEmail?: readonly string[]\n }): Promise<UsageReport> {\n const query: Record<string, string | string[]> = {\n since: options.since,\n until: options.until,\n rollup: options.rollup,\n }\n if (options.model !== undefined) query.model = options.model\n if (options.userEmail !== undefined) query.user_email = [...options.userEmail]\n const data = await invokeWithRetry(this.config, this.http, 'UsageController_list', { query })\n return data as UsageReport\n }\n}\n","// Auto-generated resource bases. Do not edit by hand.\n\nimport type { ModusConfig } from '../../../_config.js'\nimport type { HttpClient } from '../../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../../_request.js'\nimport { validatePageSize } from '../../../_validation.js'\nimport type { ToolCatalogEntry } from '../../../types/tools.js'\n\n/** Generated base for the management `tools` resource. */\nexport class ToolsResourceBase {\n /** @internal */\n constructor(\n protected readonly http: HttpClient,\n protected readonly config: ModusConfig,\n ) {}\n\n /**\n * List available tools.\n *\n * Returns a page of known tool/integration surfaces a scope can select in its toolset, with the\n * fixed actions for built-in tools.\n *\n * **Requires:** `scopes:read`\n *\n * @param options.pageSize - Items per page. Defaults to 25.\n * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit\n * for the first page.\n * @returns A page of tools.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<ToolCatalogEntry>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken)\n }\n\n protected async listPage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<ToolCatalogEntry>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ToolsController_list', {\n query: aipListParams(pageSize, pageToken) as Record<\n string,\n string | number | boolean | undefined | null\n >,\n }),\n )\n return buildAipPage(\n data,\n 'tools',\n (raw) => raw as ToolCatalogEntry,\n (token) => this.listPage(pageSize, token),\n )\n }\n}\n","import { ToolsResourceBase } from '../_generated/resources/management/tools.js'\n\n/** Browse the catalog of tool and integration surfaces a scope can select in its toolset. */\nexport class ManagementToolsResource extends ToolsResourceBase {}\n","import type { ModusConfig } from '../_config.js'\nimport type { components } from '../_generated/v1.js'\nimport type { HttpClient } from '../_http.js'\nimport { invokeWithRetry } from '../_request.js'\n\nexport type MemberGroup = components['schemas']['MemberGroupDto']\nexport type OrgMember = components['schemas']['OrgMemberDto']\n\nexport class ManagementUsersResource {\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /** List member groups in the organization. */\n async listMemberGroups(): Promise<MemberGroup[]> {\n const data = (await invokeWithRetry(\n this.config, this.http, 'MemberGroupsController_list',\n )) as { groups: MemberGroup[] }\n return data.groups\n }\n\n /** List organization members. */\n async listOrgMembers(): Promise<OrgMember[]> {\n const data = (await invokeWithRetry(\n this.config, this.http, 'OrgMembersController_list',\n )) as { members: OrgMember[] }\n return data.members\n }\n}\n","import { ModusClientBase } from '../_client-base.js'\nimport type { ModusOptions } from '../_config.js'\nimport { ManagementWorkflowsResource } from './workflows/agents.js'\nimport { ManagementContextResource } from './context/context.js'\nimport { ManagementScopesResource } from './scopes/skills.js'\nimport { ManagementUsageResource } from './usage.js'\nimport { ManagementToolsResource } from './tools.js'\nimport { ManagementUsersResource } from './users.js'\n\n/**\n * Configure scopes, workflows, context, usage, tools, and users.\n *\n * Call path: `const mgmt = new ModusManagement(...)` then `mgmt.scopes`, `mgmt.context`, …\n *\n * @param options - Client configuration (`apiKey`, `baseUrl`, `timeoutMs`, `maxRetries`).\n */\nexport class ModusManagement extends ModusClientBase {\n readonly scopes: ManagementScopesResource\n readonly workflows: ManagementWorkflowsResource\n readonly context: ManagementContextResource\n readonly usage: ManagementUsageResource\n readonly tools: ManagementToolsResource\n readonly users: ManagementUsersResource\n\n constructor(options: ModusOptions = {}) {\n super(options)\n this.scopes = new ManagementScopesResource(this.http, this.config)\n this.workflows = new ManagementWorkflowsResource(this.http, this.config)\n this.context = new ManagementContextResource(this.http, this.config)\n this.usage = new ManagementUsageResource(this.http, this.config)\n this.tools = new ManagementToolsResource(this.http, this.config)\n this.users = new ManagementUsersResource(this.http, this.config)\n }\n}\n\nexport type { ModusOptions }\nexport type { ModusConfig } from '../_config.js'\nexport type { ManagementScopesResource } from './scopes/skills.js'\nexport type { ScopeMemoriesResource } from './scopes/memories.js'\nexport type { ScopeEvaluationsResource } from './scopes/evaluations.js'\nexport type { ScopeSupervisionResource, SetSupervisionRequest, Supervision } from './scopes/supervision.js'\nexport type { McpExposureCatalog, McpExposureCatalogRequest } from './scopes/mcp-exposure-catalog.js'\nexport type {\n AddScopeInterface,\n ScopeInterface,\n ScopeInterfacesResource,\n UpdateScopeInterface,\n} from './scopes/interfaces.js'\nexport type { ManagementWorkflowsResource } from './workflows/agents.js'\nexport type {\n AddAgentInterface,\n AgentInterface,\n UpdateAgentInterface,\n WorkflowInterfacesResource,\n} from './workflows/interfaces.js'\nexport type { ManagementContextResource } from './context/context.js'\nexport type { ManagementContextItemsResource } from './context/items.js'\nexport type { BatchUploadOptions, ManagementContextFilesResource } from './context/files.js'\nexport type { ManagementDashboardElementsResource, ManagementDashboardsResource } from './context/dashboards.js'\nexport type { ManagementUsageResource } from './usage.js'\nexport type { ManagementToolsResource } from './tools.js'\nexport type { ManagementUsersResource, MemberGroup, OrgMember } from './users.js'\nexport type {\n AddEvaluationCase,\n EvaluationCase,\n EvaluationConfig,\n EvaluationRun,\n EvaluationRunWithResults,\n TriggerEvaluationRunResponse,\n UpdateEvaluationCase,\n UpdateEvaluationConfig,\n} from './types/evaluations.js'\nexport type { JsonObjectInput, JsonObjectListInput } from './types/json-blob.js'\nexport type { CreatedContextItem } from '../types/context.js'\nexport type { ToolCatalogEntry } from '../types/tools.js'\nexport type {\n UsageBucket,\n UsageEntity,\n UsageEntityStatus,\n UsageReport,\n UsageRollup,\n UsageTotals,\n UsageUser,\n UsageUsersReport,\n} from '../types/usage.js'\nexport type {\n CreateScopeOptions,\n UpdateScopeOptions,\n CreateSkillOptions,\n UpdateSkillOptions,\n} from './scopes/skills.js'\nexport type {\n CreateWorkflowOptions,\n UpdateWorkflowOptions,\n CreateAgentOptions,\n UpdateAgentOptions,\n TriggerInput,\n AgentSelectionInput,\n WorkflowGraphInput,\n} from './workflows/agents.js'\nexport type { UserFeedback } from './context/context.js'\nexport type {\n ContextItemAccessUpdate,\n ContextItemDeletion,\n ContextItemMove,\n UpdateContextItemAccessInput,\n} from '../types/context.js'\nexport type {\n BulkFinalizeResult,\n BulkUploadFromUrlsResult,\n BulkUploadUrlsResult,\n FinalizeInput,\n FailedUploadFromUrl,\n FailedUploadUrl,\n FinalizeFailure,\n FileUpload,\n FileUploadStatus,\n UploadDirFailure,\n UploadDirResult,\n UploadFileInput,\n UploadFromUrlInput,\n UploadProgress,\n UploadProgressCallback,\n UploadUrlInput,\n UploadUrlSlot,\n WaitUntil,\n} from '../types/context-files.js'\nexport type {\n CreateDashboardElementInput,\n CreateDashboardInput,\n Dashboard,\n DashboardDraftSnapshot,\n DashboardElementKind,\n DashboardElementLayout,\n DashboardElementPatch,\n DashboardElementResult,\n DashboardElementsList,\n DashboardElementSummary,\n DashboardLayoutElement,\n DashboardPublishResult,\n DashboardVersion,\n DashboardView,\n PublishDashboardInput,\n TransferDashboardOwnershipInput,\n UpdateDashboardAccessInput,\n UpdateDashboardDraftInput,\n UpdateDashboardElementInput,\n UpdateDashboardLayoutInput,\n} from '../types/context-dashboards.js'\nexport type { PlatformToolsetEntry, ToolsetInput, ToolsetRules, ToolsetSlot } from './types/toolset.js'\nexport type {\n Memory,\n MemorySearchRequest,\n MemorySearchResult,\n MemoryUpdate,\n} from './types/memories.js'\n"],"mappings":";;;;;;;;;;;;;;;;AAWO,IAAM,wBAAN,MAA4B;AAAA;AAAA,EAEjC,YACqB,MACA,QACnB;AAFmB;AACA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8BH,KAAK,UAOD,CAAC,GAA4B;AAC/B,UAAM,WAAW,QAAQ,YAAY;AACrC,qBAAiB,QAAQ;AACzB,WAAO,KAAK,SAAS,U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