@schlenkr/ragents 0.1.13 → 0.1.15

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.
Files changed (145) hide show
  1. package/apps/server/package.json +1 -1
  2. package/apps/server/src/api/contracts.ts +19 -1
  3. package/apps/server/src/api/core-methods.ts +12 -0
  4. package/apps/server/src/chat-handler.ts +19 -0
  5. package/apps/server/src/host-api.json +2 -0
  6. package/apps/server/src/host-api.ts +2 -2
  7. package/apps/server/src/plugin-build/build.ts +1 -1
  8. package/apps/server/src/plugin-support/actor-programs/app-project.ts +61 -17
  9. package/apps/server/src/plugin-support/actor-programs/contract.ts +18 -1
  10. package/apps/server/src/plugin-support/actor-programs/service.ts +22 -1
  11. package/apps/server/src/plugin-support/plugin-folder.ts +14 -1
  12. package/apps/server/src/plugin-support/run-scripts.ts +27 -2
  13. package/apps/server/src/profile/compose.ts +2 -0
  14. package/apps/server/src/provider.ts +31 -6
  15. package/apps/server/src/ragents/chat-projection.ts +7 -0
  16. package/apps/server/src/ragents/global-chat.ts +5 -1
  17. package/apps/server/src/ragents/run-script-tools.ts +66 -0
  18. package/apps/server/src/ragents/session.ts +122 -60
  19. package/apps/server/src/title-compactor.ts +1 -1
  20. package/apps/web/dist/assets/{highlighted-body-KPVGNVTW-CpPi6QLr.js → highlighted-body-KPVGNVTW-BwD4uYEe.js} +1 -1
  21. package/apps/web/dist/assets/main-KBrc5Q77.js +11 -0
  22. package/apps/web/dist/assets/{mermaid-HWGCJPDP-q-mf1kLN.js → mermaid-HWGCJPDP-CSCkaArr.js} +88 -88
  23. package/apps/web/dist/assets/runPanel-BjG5NBKm.js +26 -0
  24. package/apps/web/dist/help/guide-clients.html +21 -4
  25. package/apps/web/dist/help/guide-clients.md +23 -4
  26. package/apps/web/dist/help/guide-plugins.html +12 -2
  27. package/apps/web/dist/help/guide-plugins.md +9 -2
  28. package/apps/web/dist/help/guide-programs.html +8 -2
  29. package/apps/web/dist/help/guide-programs.md +9 -2
  30. package/apps/web/dist/help/guide-runtime.html +3 -2
  31. package/apps/web/dist/help/guide-runtime.md +3 -2
  32. package/apps/web/dist/help/index.html +1 -1
  33. package/apps/web/dist/help/mini-app.css +16 -2
  34. package/apps/web/dist/host-web.json +13 -13
  35. package/apps/web/dist/index.html +2 -2
  36. package/apps/web/dist/run-panel.html +2 -2
  37. package/apps/web/package.json +1 -1
  38. package/apps/web/src/App.tsx +12 -1
  39. package/apps/web/src/PluginRegistry.tsx +2 -2
  40. package/apps/web/src/SessionList.tsx +7 -6
  41. package/apps/web/src/SettingsModal.tsx +3 -3
  42. package/apps/web/src/actor-programs/client-ui/FilePicker.tsx +1 -1
  43. package/apps/web/src/api.ts +2 -0
  44. package/apps/web/src/run-overview.ts +1 -1
  45. package/apps/web/src/run-panel/RunPanelApp.tsx +1 -1
  46. package/apps/web/src/run-panel/RunPanelMenu.tsx +47 -11
  47. package/apps/web/src/ui/relative-time.ts +1 -1
  48. package/bundles/ragents.activity/ragents-bundle.json +1 -1
  49. package/bundles/ragents.actor-programs/ragents-bundle.json +4 -2
  50. package/bundles/ragents.actor-programs/server/index.js +437 -24
  51. package/bundles/ragents.actor-programs/server/index.js.map +4 -4
  52. package/bundles/ragents.actor-programs/web/index.js.map +1 -1
  53. package/bundles/ragents.ask/ragents-bundle.json +2 -2
  54. package/bundles/ragents.ask/server/index.js +1 -0
  55. package/bundles/ragents.ask/server/index.js.map +2 -2
  56. package/bundles/ragents.browser/ragents-bundle.json +1 -1
  57. package/bundles/ragents.documents/ragents-bundle.json +2 -2
  58. package/bundles/ragents.documents/web/classes.json +1 -1
  59. package/bundles/ragents.documents/web/index.js +1 -1
  60. package/bundles/ragents.documents/web/index.js.map +2 -2
  61. package/bundles/ragents.lsp-fsharp/ragents-bundle.json +1 -1
  62. package/bundles/ragents.lsp-roslyn/ragents-bundle.json +1 -1
  63. package/bundles/ragents.lsp-typescript/ragents-bundle.json +1 -1
  64. package/bundles/ragents.model-relay/ragents-bundle.json +1 -1
  65. package/bundles/ragents.orchestration/ragents-bundle.json +7 -4
  66. package/bundles/ragents.orchestration/server/chunks/chunk-QS3WJ3D7.js +11 -0
  67. package/bundles/ragents.orchestration/server/chunks/chunk-QS3WJ3D7.js.map +7 -0
  68. package/bundles/ragents.orchestration/server/exports/server/contract.js +9 -0
  69. package/bundles/ragents.orchestration/server/exports/server/contract.js.map +7 -0
  70. package/bundles/ragents.orchestration/server/index.js +49 -3
  71. package/bundles/ragents.orchestration/server/index.js.map +2 -2
  72. package/bundles/ragents.orchestration/surface.hbs +5 -0
  73. package/bundles/ragents.orchestration/web/index.js +3 -3
  74. package/bundles/ragents.orchestration/web/index.js.map +2 -2
  75. package/bundles/ragents.overseer/ragents-bundle.json +4 -3
  76. package/bundles/ragents.overseer/web/classes.json +1 -1
  77. package/bundles/ragents.overseer/web/index.js +1 -1
  78. package/bundles/ragents.overseer/web/index.js.map +4 -4
  79. package/bundles/ragents.processes/ragents-bundle.json +2 -2
  80. package/bundles/ragents.processes/web/classes.json +1 -1
  81. package/bundles/ragents.processes/web/index.js +1 -1
  82. package/bundles/ragents.processes/web/index.js.map +2 -2
  83. package/bundles/ragents.product/ragents-bundle.json +1 -1
  84. package/bundles/ragents.profile-distribution/ragents-bundle.json +1 -1
  85. package/bundles/ragents.reference/actors/notebook/package.json +16 -0
  86. package/bundles/ragents.reference/actors/notebook/src/client.tsx +31 -0
  87. package/bundles/ragents.reference/actors/notebook/src/server.ts +27 -0
  88. package/bundles/ragents.reference/actors/notebook/tests/program.test.ts +27 -0
  89. package/bundles/ragents.reference/ragents-bundle.json +4 -3
  90. package/bundles/ragents.reference/run-scripts/quick-note/RUN.md +14 -0
  91. package/bundles/ragents.reference/run-scripts/quick-note/package.json +9 -0
  92. package/bundles/ragents.reference/run-scripts/quick-note/src/server.ts +29 -0
  93. package/bundles/ragents.reference/run-scripts/quick-note/tests/program.test.ts +43 -0
  94. package/bundles/ragents.reference/run-scripts/run-roster/RUN.md +19 -0
  95. package/bundles/ragents.reference/run-scripts/run-roster/package.json +9 -0
  96. package/bundles/ragents.reference/run-scripts/run-roster/src/server.ts +26 -0
  97. package/bundles/ragents.reference/run-scripts/run-roster/tests/program.test.ts +47 -0
  98. package/bundles/ragents.todo/ragents-bundle.json +1 -1
  99. package/bundles/ragents.transcript/ragents-bundle.json +1 -1
  100. package/bundles/ragents.watch/ragents-bundle.json +1 -1
  101. package/bundles/ragents.workspace/ragents-bundle.json +2 -2
  102. package/bundles/ragents.workspace/web/classes.json +1 -1
  103. package/bundles/ragents.workspace/web/index.js +1 -1
  104. package/bundles/ragents.workspace/web/index.js.map +2 -2
  105. package/package.json +3 -3
  106. package/packages/ragents/src/domain/vocabulary.ts +4 -0
  107. package/packages/ragents/src/index.ts +3 -1
  108. package/packages/ragents/src/plugin-host.ts +62 -10
  109. package/packages/ragents/src/plugin-types.ts +11 -0
  110. package/packages/ragents/src/runtime/guards.ts +2 -1
  111. package/packages/ragents/src/typescript/async-compiler.ts +11 -1
  112. package/plugins/ragents.actor-programs/server/index.ts +3 -0
  113. package/plugins/ragents.actor-programs/server/runtime.ts +424 -28
  114. package/plugins/ragents.actor-programs/server/script-state.ts +54 -0
  115. package/plugins/ragents.actor-programs/server/tool-contributor.ts +2 -0
  116. package/plugins/ragents.ask/server/ask-tool.ts +1 -0
  117. package/plugins/ragents.documents/web/DocumentViewer.tsx +2 -2
  118. package/plugins/ragents.orchestration/ragents-plugin.json +1 -0
  119. package/plugins/ragents.orchestration/server/contract.ts +14 -0
  120. package/plugins/ragents.orchestration/server/index.ts +4 -1
  121. package/plugins/ragents.orchestration/server/surface-tool.ts +58 -2
  122. package/plugins/ragents.orchestration/surface.hbs +5 -0
  123. package/plugins/ragents.orchestration/web/ExecutionsPanel.tsx +1 -1
  124. package/plugins/ragents.orchestration/web/FlowInspector.tsx +1 -1
  125. package/plugins/ragents.orchestration/web/JournalStatus.tsx +1 -1
  126. package/plugins/ragents.orchestration/web/format.ts +1 -1
  127. package/plugins/ragents.overseer/web/index.tsx +51 -3
  128. package/plugins/ragents.processes/web/processes.ts +1 -1
  129. package/plugins/ragents.reference/actors/notebook/package.json +16 -0
  130. package/plugins/ragents.reference/actors/notebook/src/client.tsx +31 -0
  131. package/plugins/ragents.reference/actors/notebook/src/server.ts +27 -0
  132. package/plugins/ragents.reference/actors/notebook/tests/program.test.ts +27 -0
  133. package/plugins/ragents.reference/run-scripts/quick-note/RUN.md +14 -0
  134. package/plugins/ragents.reference/run-scripts/quick-note/package.json +9 -0
  135. package/plugins/ragents.reference/run-scripts/quick-note/src/server.ts +29 -0
  136. package/plugins/ragents.reference/run-scripts/quick-note/tests/program.test.ts +43 -0
  137. package/plugins/ragents.reference/run-scripts/run-roster/RUN.md +19 -0
  138. package/plugins/ragents.reference/run-scripts/run-roster/package.json +9 -0
  139. package/plugins/ragents.reference/run-scripts/run-roster/src/server.ts +26 -0
  140. package/plugins/ragents.reference/run-scripts/run-roster/tests/program.test.ts +47 -0
  141. package/plugins/ragents.workspace/web/FileBrowser.tsx +1 -1
  142. package/scripts/agent/agent-cli.ts +46 -2
  143. package/scripts/package/ragents.mjs +3 -1
  144. package/apps/web/dist/assets/main-DJmCHGzM.js +0 -11
  145. package/apps/web/dist/assets/runPanel-nk_aMxSn.js +0 -21
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../plugins/ragents.ask/server/index.ts", "../../../plugins/ragents.ask/server/answer-method.ts", "../../../plugins/ragents.ask/contract.ts", "../../../plugins/ragents.ask/server/ask-service.ts", "../../../plugins/ragents.ask/ask-payload.ts", "../../../plugins/ragents.ask/server/tool-contributor.ts", "../../../plugins/ragents.ask/server/ask-tool.ts"],
4
- "sourcesContent": ["import type { RAgentsPlugin } from \"@ragents/engine\";\nimport { pluginAsset } from \"@ragents/host/plugin-support/plugin-folder.js\";\nimport type { PluginModule } from \"@ragents/host/plugin-support/plugin-module.js\";\nimport { handlebarsPrompt } from \"@ragents/host/plugin-support/prompt.js\";\nimport { runGuardToken } from \"@ragents/host/ragents/host-services.js\";\nimport { runtimeBridgeToken } from \"@ragents/host/ragents/runtime-bridge.js\";\nimport { createAnswerMethod } from \"./answer-method.js\";\nimport { RuntimeAskService } from \"./ask-service.js\";\nimport { askServiceToken } from \"./contract.js\";\nimport { createAskToolContributor } from \"./tool-contributor.js\";\n\nconst askPlugin: RAgentsPlugin = {\n manifest: { id: \"ragents.ask\" },\n register: (host) => {\n const service = new RuntimeAskService();\n host.provide(askServiceToken, service);\n host.provide(runtimeBridgeToken, { bind: (runtime) => service.bind(runtime) });\n host.prompts(handlebarsPrompt(\"ragents.ask.prompt\", 480, pluginAsset(\"ragents.ask\", \"ask.hbs\")));\n host.functions(createAskToolContributor(service));\n host.methods(createAnswerMethod(service, host.service(runGuardToken)));\n },\n};\n\nexport const plugin: PluginModule = { create: () => askPlugin };\n", "import { DomainError, implement, type MethodContribution } from \"@ragents/engine\";\nimport { askContracts } from \"../contract.js\";\nimport type { RuntimeAskService } from \"./ask-service.js\";\n\nexport const createAnswerMethod = (\n service: RuntimeAskService,\n ensureSession: (runId: string) => void,\n): MethodContribution => implement(askContracts.answer, ({ runId, actionId, answer, dismiss }) => {\n if (dismiss !== true && (typeof answer !== \"string\" || answer.trim() === \"\")) {\n throw new DomainError(\"answer-missing\", \"answer is required unless the question is dismissed\", 400);\n }\n ensureSession(runId);\n service.answer(runId, actionId, { ...(answer !== undefined ? { answer } : {}), ...(dismiss !== undefined ? { dismiss } : {}) });\n return null;\n});\n", "import { Type } from \"typebox\";\nimport { defineOperation } from \"@ragents/engine/src/rpc/contract\";\n\nexport const askContracts = {\n answer: defineOperation({\n id: \"ragents.ask.answer\",\n description: \"Answer or dismiss a question of the run. Rights: runs.read and runs.write.\",\n rights: [\"runs.read\", \"runs.write\"],\n input: Type.Object({\n runId: Type.String({ minLength: 1, maxLength: 64, description: \"Run id\" }),\n actionId: Type.String({ minLength: 1, maxLength: 80, description: \"Question id\" }),\n answer: Type.Optional(Type.String({ description: \"The user's answer\" })),\n dismiss: Type.Optional(Type.Boolean({ description: \"true dismisses the question without an answer\" })),\n }, { additionalProperties: false }),\n result: Type.Null(),\n }),\n};\n", "import { randomUUID } from \"node:crypto\";\nimport {\n DomainError,\n type Action,\n type CommandContext,\n type JournalEvent,\n type JsonValue,\n type Orchestration,\n} from \"@ragents/engine\";\nimport { askPayloadOf, ASK_PLUGIN_ID, SUPERSEDED_ANSWER, supersedingInputOf } from \"../ask-payload.js\";\nimport { DISMISSED_ANSWER, type AskCall, type AskRequest, type AskService } from \"./contract.js\";\n\nconst answerOf = (decision: \"approved\" | \"dismissed\", result: unknown): string =>\n decision !== \"approved\"\n ? supersedingInputOf(result) === undefined ? DISMISSED_ANSWER : SUPERSEDED_ANSWER\n : typeof result === \"string\" ? result : result === null || result === undefined ? \"\" : JSON.stringify(result);\n\nconst resolvedAnswerOf = (action: Action): string | null =>\n action.status === \"pending\" ? null : answerOf(action.status, action.result);\n\nconst humanInputPendingFor = (runtime: Orchestration, runId: string, actorId: string): boolean =>\n [...runtime.state(runId).inputs.values()].some((input) =>\n input.actorId === actorId && input.origin === \"human\" && input.lifecycle.kind === \"pending\");\n\ninterface Waiter {\n runId: string;\n /** The actor whose running turn waits for the answer; null for a question asked outside a turn. */\n blockedActorId: string | null;\n settle: (answer: string) => void;\n}\n\nexport class RuntimeAskService implements AskService {\n #runtime: Orchestration | undefined;\n readonly #waiters = new Map<string, Waiter>();\n readonly #aborting = new Set<string>();\n\n bind(runtime: Orchestration): void {\n if (this.#runtime) throw new Error(\"The ask service is already bound to a runtime\");\n this.#runtime = runtime;\n runtime.subscribe((events) => this.#onJournal(events));\n }\n\n ask(call: AskCall, request: AskRequest, signal: AbortSignal | undefined): Promise<string> {\n const runtime = this.#requireRuntime();\n if (call.turnId && humanInputPendingFor(runtime, call.runId, call.agentId)) return Promise.resolve(SUPERSEDED_ANSWER);\n const context: CommandContext = {\n actorId: call.agentId,\n commandId: call.commandId,\n ...(call.turnId ? { turnId: call.turnId, correlationId: call.turnId, causationId: call.turnId } : {}),\n };\n runtime.proposeAction(context, call.runId, {\n owner: ASK_PLUGIN_ID,\n title: request.question,\n description: request.description,\n parameters: request.parameters,\n input: { label: \"Answer\", placeholder: null, required: true },\n payload: {\n question: request.question,\n options: [...request.options],\n multi: request.multi === true,\n ...(request.recipient ? { recipient: request.recipient } : {}),\n },\n });\n const proposed = runtime.events(call.runId).find((event) =>\n event.type === \"action.proposed\" && event.commandId === call.commandId);\n if (proposed?.type !== \"action.proposed\") {\n throw new Error(`The question from ${call.agentId} was not created in the journal of ${call.runId}`);\n }\n return this.#awaitAnswer(call.runId, proposed.payload.actionId, call.turnId ? call.agentId : null, signal);\n }\n\n answer(runId: string, actionId: string, input: { answer?: string; dismiss?: boolean }): void {\n const runtime = this.#requireRuntime();\n const state = runtime.state(runId);\n const action = state.actions.get(actionId);\n if (!action || action.owner !== ASK_PLUGIN_ID) {\n throw new DomainError(\"question-not-found\", `Question ${actionId} does not exist in run ${runId}.`, 404);\n }\n runtime.resolveAction(\n { actorId: state.ownerId, commandId: `ask-answer:${actionId}:${randomUUID()}` },\n runId,\n actionId,\n input.dismiss === true\n ? { decision: \"dismissed\", result: null }\n : { decision: \"approved\", result: input.answer ?? null },\n );\n }\n\n withdraw(runId: string, actionId: string): void {\n this.#dismiss(runId, actionId, \"ask-withdraw\", null, DISMISSED_ANSWER);\n }\n\n #supersede(runId: string, actionId: string, inputId: string): void {\n try {\n this.#dismiss(runId, actionId, \"ask-supersede\", { supersededBy: inputId }, SUPERSEDED_ANSWER);\n } catch (error) {\n console.error(`Question ${actionId} could not be closed for message ${inputId}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n #dismiss(runId: string, actionId: string, commandPrefix: string, result: JsonValue, answer: string): void {\n const runtime = this.#requireRuntime();\n const state = runtime.state(runId);\n const action = state.actions.get(actionId);\n if (action?.owner !== ASK_PLUGIN_ID || action.status !== \"pending\") return;\n this.#aborting.add(actionId);\n try {\n runtime.resolveAction(\n { actorId: state.ownerId, commandId: `${commandPrefix}:${actionId}:${randomUUID()}` },\n runId,\n actionId,\n { decision: \"dismissed\", result },\n );\n } finally {\n this.#aborting.delete(actionId);\n }\n this.#waiters.get(actionId)?.settle(answer);\n }\n\n #awaitAnswer(runId: string, actionId: string, blockedActorId: string | null, signal: AbortSignal | undefined): Promise<string> {\n const runtime = this.#requireRuntime();\n const action = runtime.state(runId).actions.get(actionId);\n if (!action) throw new Error(`Question ${actionId} does not exist in run ${runId}`);\n const settled = resolvedAnswerOf(action);\n if (settled !== null) return Promise.resolve(settled);\n return new Promise<string>((resolve, reject) => {\n const abort = () => {\n this.#waiters.delete(actionId);\n this.#aborting.add(actionId);\n try {\n const state = runtime.state(runId);\n const pending = state.actions.get(actionId);\n if (pending?.status === \"pending\") {\n runtime.resolveAction(\n { actorId: state.ownerId, commandId: `ask-abort:${actionId}:${randomUUID()}` },\n runId,\n actionId,\n { decision: \"dismissed\", result: null },\n );\n }\n reject(new Error(\"Waiting for the answer was cancelled.\"));\n } catch (error) {\n reject(error);\n } finally {\n this.#aborting.delete(actionId);\n }\n };\n if (signal?.aborted) {\n abort();\n return;\n }\n signal?.addEventListener(\"abort\", abort, { once: true });\n this.#waiters.set(actionId, {\n runId,\n blockedActorId,\n settle: (answer) => {\n signal?.removeEventListener(\"abort\", abort);\n this.#waiters.delete(actionId);\n resolve(answer);\n },\n });\n });\n }\n\n #onJournal(events: JournalEvent[]): void {\n for (const event of events) {\n if (event.type === \"actor.input.enqueued\") {\n if (event.payload.origin !== \"human\") continue;\n const { actorId, inputId } = event.payload;\n for (const [actionId, waiter] of this.#waiters) {\n if (waiter.runId !== event.runId || waiter.blockedActorId !== actorId) continue;\n queueMicrotask(() => this.#supersede(event.runId, actionId, inputId));\n }\n continue;\n }\n if (event.type !== \"action.resolved\") continue;\n if (this.#aborting.has(event.payload.actionId)) continue;\n const resolved = this.#requireRuntime().state(event.runId).actions.get(event.payload.actionId);\n if (resolved?.owner !== ASK_PLUGIN_ID) continue;\n const answer = answerOf(event.payload.decision, event.payload.result);\n const waiter = this.#waiters.get(event.payload.actionId);\n if (waiter) {\n waiter.settle(answer);\n continue;\n }\n queueMicrotask(() => this.#enqueueAnswer(event.runId, event.payload.actionId, answer));\n }\n }\n\n #enqueueAnswer(runId: string, actionId: string, answer: string): void {\n try {\n const runtime = this.#requireRuntime();\n const state = runtime.state(runId);\n const action = state.actions.get(actionId);\n if (!action) return;\n const recipientId = askPayloadOf(action.payload)?.recipient ?? action.askedBy;\n const recipient = state.actors.get(recipientId);\n if (!recipient || recipient.kind === \"human\" || recipient.lifecycle.kind === \"stopped\") return;\n runtime.enqueueInput(\n { actorId: state.ownerId, commandId: `ask-input:${actionId}` },\n runId,\n {\n actorId: recipientId,\n content: `Answer to ${recipientId === action.askedBy ? \"your question\" : \"the question\"}: ${action.title}\\nAnswer: ${answer}`,\n },\n );\n } catch (error) {\n console.error(`Answer to question ${actionId} could not be enqueued as input: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n #requireRuntime(): Orchestration {\n if (!this.#runtime) throw new Error(\"The ask service is not bound to the runtime yet\");\n return this.#runtime;\n }\n}\n", "export const ASK_PLUGIN_ID = \"ragents.ask\";\n\n/** What the asking tool call gets when a person's message to the asker closes its question. */\nexport const SUPERSEDED_ANSWER = \"Not answered: the user sent a new message instead.\";\n\nexport interface AskPayload {\n question: string;\n options: string[];\n multi: boolean;\n /** The actor the question stands for when the run owner asks it outside a turn. */\n recipient?: string;\n}\n\nconst stringArrayOf = (value: unknown): string[] | undefined =>\n Array.isArray(value) && value.every((entry) => typeof entry === \"string\") ? [...value] : undefined;\n\nexport const askPayloadOf = (payload: unknown): AskPayload | undefined => {\n if (typeof payload !== \"object\" || payload === null) return undefined;\n const candidate = payload as Partial<AskPayload>;\n const options = stringArrayOf(candidate.options);\n if (typeof candidate.question !== \"string\" || !options) return undefined;\n return {\n question: candidate.question,\n options,\n multi: candidate.multi === true,\n ...(typeof candidate.recipient === \"string\" ? { recipient: candidate.recipient } : {}),\n };\n};\n\nexport const supersedingInputOf = (result: unknown): string | undefined => {\n if (typeof result !== \"object\" || result === null) return undefined;\n const { supersededBy } = result as { supersededBy?: unknown };\n return typeof supersededBy === \"string\" ? supersededBy : undefined;\n};\n", "import type { ToolContributor } from \"@ragents/engine\";\nimport { toolDescriptorFrom } from \"@ragents/host/plugin-support/agent-tool.js\";\nimport { facesOperator } from \"@ragents/host/plugin-support/tool-availability.js\";\nimport { askToolMetadata, createAskTool } from \"./ask-tool.js\";\nimport type { AskService } from \"./contract.js\";\n\nexport const createAskToolContributor = (service: AskService): ToolContributor => ({\n name: \"ragents.ask\",\n descriptors: [toolDescriptorFrom(askToolMetadata, facesOperator)],\n tools: () => [createAskTool(service)],\n});\n", "import { Type } from \"typebox\";\nimport { defineRunFunction, type RunFunction } from \"@ragents/engine\";\nimport { facesOperator } from \"@ragents/host/plugin-support/tool-availability.js\";\nimport type { AskService } from \"./contract.js\";\n\nexport const askToolMetadata = {\n name: \"ask_user\",\n label: \"Question\",\n description: \"Asks the user for a required decision with answer options and waits for the answer.\",\n longDescription: \"Always use this tool when you need a decision from the user \"\n + \"(e.g. choosing a branch or a time range), instead of only asking the question as text. \"\n + \"With multi=true the user may choose several options; the answer is then joined with '; '. \"\n + \"Instead of choosing an option, the user can always answer freely - so expect \"\n + \"the answer to be arbitrary text.\",\n} as const;\n\nexport const createAskTool = (service: AskService): RunFunction =>\n defineRunFunction({\n ...askToolMetadata,\n schema: Type.Object({\n question: Type.String({ description: \"The question to the user, short and concrete\" }),\n options: Type.Array(Type.String(), { description: \"Answer options (2 to 6)\" }),\n multi: Type.Optional(Type.Boolean({ description: \"true = multiple choice allowed\" })),\n }),\n resultSchema: Type.String(),\n available: facesOperator,\n executionMode: \"sequential\",\n run: (scope, toolCallId, input) =>\n service.ask(\n {\n runId: scope.caller.runId,\n agentId: scope.caller.actorId,\n turnId: scope.caller.turnId,\n commandId: scope.context(toolCallId).commandId,\n },\n { question: input.question, options: input.options, multi: input.mult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,iCAAiC,CAAC,CAAC;AAAA,EACtF,CAAC;AAAA,EACD,cAAcA,MAAK,OAAO;AAAA,EAC1B,WAAW;AAAA,EACX,eAAe;AAAA,EACf,KAAK,CAAC,OAAO,YAAY,UACvB,QAAQ;AAAA,IACN;AAAA,MACE,OAAO,MAAM,OAAO;AAAA,MACpB,SAAS,MAAM,OAAO;AAAA,MACtB,QAAQ,MAAM,OAAO;AAAA,MACrB,WAAW,MAAM,QAAQ,UAAU,EAAE;AAAA,IACvC;AAAA,IACA,EAAE,UAAU,MAAM,UAAU,SAAS,MAAM,SAAS,OAAO,MAAM,UAAU,KAAK;AAAA,IAChF,MAAM;AAAA,EACR;AACJ,CAAC;;;ADhCI,IAAM,2BAA2B,CAAC,aAA0C;AAAA,EACjF,MAAM;AAAA,EACN,aAAa,CAAC,mBAAmB,iBAAiBC,cAAa,CAAC;AAAA,EAChE,OAAO,MAAM,CAAC,cAAc,OAAO,CAAC;AACtC;;;ALCA,IAAM,YAA2B;AAAA,EAC/B,UAAU,EAAE,IAAI,cAAc;AAAA,EAC9B,UAAU,CAAC,SAAS;AAClB,UAAM,UAAU,IAAI,kBAAkB;AACtC,SAAK,QAAQ,iBAAiB,OAAO;AACrC,SAAK,QAAQ,oBAAoB,EAAE,MAAM,CAAC,YAAY,QAAQ,KAAK,OAAO,EAAE,CAAC;AAC7E,SAAK,QAAQ,iBAAiB,sBAAsB,KAAK,YAAY,eAAe,SAAS,CAAC,CAAC;AAC/F,SAAK,UAAU,yBAAyB,OAAO,CAAC;AAChD,SAAK,QAAQ,mBAAmB,SAAS,KAAK,QAAQ,aAAa,CAAC,CAAC;AAAA,EACvE;AACF;AAEO,IAAM,SAAuB,EAAE,QAAQ,MAAM,UAAU;",
4
+ "sourcesContent": ["import type { RAgentsPlugin } from \"@ragents/engine\";\nimport { pluginAsset } from \"@ragents/host/plugin-support/plugin-folder.js\";\nimport type { PluginModule } from \"@ragents/host/plugin-support/plugin-module.js\";\nimport { handlebarsPrompt } from \"@ragents/host/plugin-support/prompt.js\";\nimport { runGuardToken } from \"@ragents/host/ragents/host-services.js\";\nimport { runtimeBridgeToken } from \"@ragents/host/ragents/runtime-bridge.js\";\nimport { createAnswerMethod } from \"./answer-method.js\";\nimport { RuntimeAskService } from \"./ask-service.js\";\nimport { askServiceToken } from \"./contract.js\";\nimport { createAskToolContributor } from \"./tool-contributor.js\";\n\nconst askPlugin: RAgentsPlugin = {\n manifest: { id: \"ragents.ask\" },\n register: (host) => {\n const service = new RuntimeAskService();\n host.provide(askServiceToken, service);\n host.provide(runtimeBridgeToken, { bind: (runtime) => service.bind(runtime) });\n host.prompts(handlebarsPrompt(\"ragents.ask.prompt\", 480, pluginAsset(\"ragents.ask\", \"ask.hbs\")));\n host.functions(createAskToolContributor(service));\n host.methods(createAnswerMethod(service, host.service(runGuardToken)));\n },\n};\n\nexport const plugin: PluginModule = { create: () => askPlugin };\n", "import { DomainError, implement, type MethodContribution } from \"@ragents/engine\";\nimport { askContracts } from \"../contract.js\";\nimport type { RuntimeAskService } from \"./ask-service.js\";\n\nexport const createAnswerMethod = (\n service: RuntimeAskService,\n ensureSession: (runId: string) => void,\n): MethodContribution => implement(askContracts.answer, ({ runId, actionId, answer, dismiss }) => {\n if (dismiss !== true && (typeof answer !== \"string\" || answer.trim() === \"\")) {\n throw new DomainError(\"answer-missing\", \"answer is required unless the question is dismissed\", 400);\n }\n ensureSession(runId);\n service.answer(runId, actionId, { ...(answer !== undefined ? { answer } : {}), ...(dismiss !== undefined ? { dismiss } : {}) });\n return null;\n});\n", "import { Type } from \"typebox\";\nimport { defineOperation } from \"@ragents/engine/src/rpc/contract\";\n\nexport const askContracts = {\n answer: defineOperation({\n id: \"ragents.ask.answer\",\n description: \"Answer or dismiss a question of the run. Rights: runs.read and runs.write.\",\n rights: [\"runs.read\", \"runs.write\"],\n input: Type.Object({\n runId: Type.String({ minLength: 1, maxLength: 64, description: \"Run id\" }),\n actionId: Type.String({ minLength: 1, maxLength: 80, description: \"Question id\" }),\n answer: Type.Optional(Type.String({ description: \"The user's answer\" })),\n dismiss: Type.Optional(Type.Boolean({ description: \"true dismisses the question without an answer\" })),\n }, { additionalProperties: false }),\n result: Type.Null(),\n }),\n};\n", "import { randomUUID } from \"node:crypto\";\nimport {\n DomainError,\n type Action,\n type CommandContext,\n type JournalEvent,\n type JsonValue,\n type Orchestration,\n} from \"@ragents/engine\";\nimport { askPayloadOf, ASK_PLUGIN_ID, SUPERSEDED_ANSWER, supersedingInputOf } from \"../ask-payload.js\";\nimport { DISMISSED_ANSWER, type AskCall, type AskRequest, type AskService } from \"./contract.js\";\n\nconst answerOf = (decision: \"approved\" | \"dismissed\", result: unknown): string =>\n decision !== \"approved\"\n ? supersedingInputOf(result) === undefined ? DISMISSED_ANSWER : SUPERSEDED_ANSWER\n : typeof result === \"string\" ? result : result === null || result === undefined ? \"\" : JSON.stringify(result);\n\nconst resolvedAnswerOf = (action: Action): string | null =>\n action.status === \"pending\" ? null : answerOf(action.status, action.result);\n\nconst humanInputPendingFor = (runtime: Orchestration, runId: string, actorId: string): boolean =>\n [...runtime.state(runId).inputs.values()].some((input) =>\n input.actorId === actorId && input.origin === \"human\" && input.lifecycle.kind === \"pending\");\n\ninterface Waiter {\n runId: string;\n /** The actor whose running turn waits for the answer; null for a question asked outside a turn. */\n blockedActorId: string | null;\n settle: (answer: string) => void;\n}\n\nexport class RuntimeAskService implements AskService {\n #runtime: Orchestration | undefined;\n readonly #waiters = new Map<string, Waiter>();\n readonly #aborting = new Set<string>();\n\n bind(runtime: Orchestration): void {\n if (this.#runtime) throw new Error(\"The ask service is already bound to a runtime\");\n this.#runtime = runtime;\n runtime.subscribe((events) => this.#onJournal(events));\n }\n\n ask(call: AskCall, request: AskRequest, signal: AbortSignal | undefined): Promise<string> {\n const runtime = this.#requireRuntime();\n if (call.turnId && humanInputPendingFor(runtime, call.runId, call.agentId)) return Promise.resolve(SUPERSEDED_ANSWER);\n const context: CommandContext = {\n actorId: call.agentId,\n commandId: call.commandId,\n ...(call.turnId ? { turnId: call.turnId, correlationId: call.turnId, causationId: call.turnId } : {}),\n };\n runtime.proposeAction(context, call.runId, {\n owner: ASK_PLUGIN_ID,\n title: request.question,\n description: request.description,\n parameters: request.parameters,\n input: { label: \"Answer\", placeholder: null, required: true },\n payload: {\n question: request.question,\n options: [...request.options],\n multi: request.multi === true,\n ...(request.recipient ? { recipient: request.recipient } : {}),\n },\n });\n const proposed = runtime.events(call.runId).find((event) =>\n event.type === \"action.proposed\" && event.commandId === call.commandId);\n if (proposed?.type !== \"action.proposed\") {\n throw new Error(`The question from ${call.agentId} was not created in the journal of ${call.runId}`);\n }\n return this.#awaitAnswer(call.runId, proposed.payload.actionId, call.turnId ? call.agentId : null, signal);\n }\n\n answer(runId: string, actionId: string, input: { answer?: string; dismiss?: boolean }): void {\n const runtime = this.#requireRuntime();\n const state = runtime.state(runId);\n const action = state.actions.get(actionId);\n if (!action || action.owner !== ASK_PLUGIN_ID) {\n throw new DomainError(\"question-not-found\", `Question ${actionId} does not exist in run ${runId}.`, 404);\n }\n runtime.resolveAction(\n { actorId: state.ownerId, commandId: `ask-answer:${actionId}:${randomUUID()}` },\n runId,\n actionId,\n input.dismiss === true\n ? { decision: \"dismissed\", result: null }\n : { decision: \"approved\", result: input.answer ?? null },\n );\n }\n\n withdraw(runId: string, actionId: string): void {\n this.#dismiss(runId, actionId, \"ask-withdraw\", null, DISMISSED_ANSWER);\n }\n\n #supersede(runId: string, actionId: string, inputId: string): void {\n try {\n this.#dismiss(runId, actionId, \"ask-supersede\", { supersededBy: inputId }, SUPERSEDED_ANSWER);\n } catch (error) {\n console.error(`Question ${actionId} could not be closed for message ${inputId}: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n #dismiss(runId: string, actionId: string, commandPrefix: string, result: JsonValue, answer: string): void {\n const runtime = this.#requireRuntime();\n const state = runtime.state(runId);\n const action = state.actions.get(actionId);\n if (action?.owner !== ASK_PLUGIN_ID || action.status !== \"pending\") return;\n this.#aborting.add(actionId);\n try {\n runtime.resolveAction(\n { actorId: state.ownerId, commandId: `${commandPrefix}:${actionId}:${randomUUID()}` },\n runId,\n actionId,\n { decision: \"dismissed\", result },\n );\n } finally {\n this.#aborting.delete(actionId);\n }\n this.#waiters.get(actionId)?.settle(answer);\n }\n\n #awaitAnswer(runId: string, actionId: string, blockedActorId: string | null, signal: AbortSignal | undefined): Promise<string> {\n const runtime = this.#requireRuntime();\n const action = runtime.state(runId).actions.get(actionId);\n if (!action) throw new Error(`Question ${actionId} does not exist in run ${runId}`);\n const settled = resolvedAnswerOf(action);\n if (settled !== null) return Promise.resolve(settled);\n return new Promise<string>((resolve, reject) => {\n const abort = () => {\n this.#waiters.delete(actionId);\n this.#aborting.add(actionId);\n try {\n const state = runtime.state(runId);\n const pending = state.actions.get(actionId);\n if (pending?.status === \"pending\") {\n runtime.resolveAction(\n { actorId: state.ownerId, commandId: `ask-abort:${actionId}:${randomUUID()}` },\n runId,\n actionId,\n { decision: \"dismissed\", result: null },\n );\n }\n reject(new Error(\"Waiting for the answer was cancelled.\"));\n } catch (error) {\n reject(error);\n } finally {\n this.#aborting.delete(actionId);\n }\n };\n if (signal?.aborted) {\n abort();\n return;\n }\n signal?.addEventListener(\"abort\", abort, { once: true });\n this.#waiters.set(actionId, {\n runId,\n blockedActorId,\n settle: (answer) => {\n signal?.removeEventListener(\"abort\", abort);\n this.#waiters.delete(actionId);\n resolve(answer);\n },\n });\n });\n }\n\n #onJournal(events: JournalEvent[]): void {\n for (const event of events) {\n if (event.type === \"actor.input.enqueued\") {\n if (event.payload.origin !== \"human\") continue;\n const { actorId, inputId } = event.payload;\n for (const [actionId, waiter] of this.#waiters) {\n if (waiter.runId !== event.runId || waiter.blockedActorId !== actorId) continue;\n queueMicrotask(() => this.#supersede(event.runId, actionId, inputId));\n }\n continue;\n }\n if (event.type !== \"action.resolved\") continue;\n if (this.#aborting.has(event.payload.actionId)) continue;\n const resolved = this.#requireRuntime().state(event.runId).actions.get(event.payload.actionId);\n if (resolved?.owner !== ASK_PLUGIN_ID) continue;\n const answer = answerOf(event.payload.decision, event.payload.result);\n const waiter = this.#waiters.get(event.payload.actionId);\n if (waiter) {\n waiter.settle(answer);\n continue;\n }\n queueMicrotask(() => this.#enqueueAnswer(event.runId, event.payload.actionId, answer));\n }\n }\n\n #enqueueAnswer(runId: string, actionId: string, answer: string): void {\n try {\n const runtime = this.#requireRuntime();\n const state = runtime.state(runId);\n const action = state.actions.get(actionId);\n if (!action) return;\n const recipientId = askPayloadOf(action.payload)?.recipient ?? action.askedBy;\n const recipient = state.actors.get(recipientId);\n if (!recipient || recipient.kind === \"human\" || recipient.lifecycle.kind === \"stopped\") return;\n runtime.enqueueInput(\n { actorId: state.ownerId, commandId: `ask-input:${actionId}` },\n runId,\n {\n actorId: recipientId,\n content: `Answer to ${recipientId === action.askedBy ? \"your question\" : \"the question\"}: ${action.title}\\nAnswer: ${answer}`,\n },\n );\n } catch (error) {\n console.error(`Answer to question ${actionId} could not be enqueued as input: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n #requireRuntime(): Orchestration {\n if (!this.#runtime) throw new Error(\"The ask service is not bound to the runtime yet\");\n return this.#runtime;\n }\n}\n", "export const ASK_PLUGIN_ID = \"ragents.ask\";\n\n/** What the asking tool call gets when a person's message to the asker closes its question. */\nexport const SUPERSEDED_ANSWER = \"Not answered: the user sent a new message instead.\";\n\nexport interface AskPayload {\n question: string;\n options: string[];\n multi: boolean;\n /** The actor the question stands for when the run owner asks it outside a turn. */\n recipient?: string;\n}\n\nconst stringArrayOf = (value: unknown): string[] | undefined =>\n Array.isArray(value) && value.every((entry) => typeof entry === \"string\") ? [...value] : undefined;\n\nexport const askPayloadOf = (payload: unknown): AskPayload | undefined => {\n if (typeof payload !== \"object\" || payload === null) return undefined;\n const candidate = payload as Partial<AskPayload>;\n const options = stringArrayOf(candidate.options);\n if (typeof candidate.question !== \"string\" || !options) return undefined;\n return {\n question: candidate.question,\n options,\n multi: candidate.multi === true,\n ...(typeof candidate.recipient === \"string\" ? { recipient: candidate.recipient } : {}),\n };\n};\n\nexport const supersedingInputOf = (result: unknown): string | undefined => {\n if (typeof result !== \"object\" || result === null) return undefined;\n const { supersededBy } = result as { supersededBy?: unknown };\n return typeof supersededBy === \"string\" ? supersededBy : undefined;\n};\n", "import type { ToolContributor } from \"@ragents/engine\";\nimport { toolDescriptorFrom } from \"@ragents/host/plugin-support/agent-tool.js\";\nimport { facesOperator } from \"@ragents/host/plugin-support/tool-availability.js\";\nimport { askToolMetadata, createAskTool } from \"./ask-tool.js\";\nimport type { AskService } from \"./contract.js\";\n\nexport const createAskToolContributor = (service: AskService): ToolContributor => ({\n name: \"ragents.ask\",\n descriptors: [toolDescriptorFrom(askToolMetadata, facesOperator)],\n tools: () => [createAskTool(service)],\n});\n", "import { Type } from \"typebox\";\nimport { defineRunFunction, type RunFunction } from \"@ragents/engine\";\nimport { facesOperator } from \"@ragents/host/plugin-support/tool-availability.js\";\nimport type { AskService } from \"./contract.js\";\n\nexport const askToolMetadata = {\n name: \"ask_user\",\n label: \"Question\",\n nativeTool: true,\n description: \"Asks the user for a required decision with answer options and waits for the answer.\",\n longDescription: \"Always use this tool when you need a decision from the user \"\n + \"(e.g. choosing a branch or a time range), instead of only asking the question as text. \"\n + \"With multi=true the user may choose several options; the answer is then joined with '; '. \"\n + \"Instead of choosing an option, the user can always answer freely - so expect \"\n + \"the answer to be arbitrary text.\",\n} as const;\n\nexport const createAskTool = (service: AskService): RunFunction =>\n defineRunFunction({\n ...askToolMetadata,\n schema: Type.Object({\n question: Type.String({ description: \"The question to the user, short and concrete\" }),\n options: Type.Array(Type.String(), { description: \"Answer options (2 to 6)\" }),\n multi: Type.Optional(Type.Boolean({ description: \"true = multiple choice allowed\" })),\n }),\n resultSchema: Type.String(),\n available: facesOperator,\n executionMode: \"sequential\",\n run: (scope, toolCallId, input) =>\n service.ask(\n {\n runId: scope.caller.runId,\n agentId: scope.caller.actorId,\n turnId: scope.caller.turnId,\n commandId: scope.context(toolCallId).commandId,\n },\n { question: input.question, options: input.options, multi: input.multi === true },\n scope.signal,\n ),\n });\n"],
5
+ "mappings": ";;;;;;;;AACA,SAAS,mBAAmB;AAE5B,SAAS,wBAAwB;AACjC,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;;;ACLnC,SAAS,aAAa,iBAA0C;;;ACAhE,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAEzB,IAAM,eAAe;AAAA,EAC1B,QAAQ,gBAAgB;AAAA,IACtB,IAAI;AAAA,IACJ,aAAa;AAAA,IACb,QAAQ,CAAC,aAAa,YAAY;AAAA,IAClC,OAAO,KAAK,OAAO;AAAA,MACjB,OAAO,KAAK,OAAO,EAAE,WAAW,GAAG,WAAW,IAAI,aAAa,SAAS,CAAC;AAAA,MACzE,UAAU,KAAK,OAAO,EAAE,WAAW,GAAG,WAAW,IAAI,aAAa,cAAc,CAAC;AAAA,MACjF,QAAQ,KAAK,SAAS,KAAK,OAAO,EAAE,aAAa,oBAAoB,CAAC,CAAC;AAAA,MACvE,SAAS,KAAK,SAAS,KAAK,QAAQ,EAAE,aAAa,gDAAgD,CAAC,CAAC;AAAA,IACvG,GAAG,EAAE,sBAAsB,MAAM,CAAC;AAAA,IAClC,QAAQ,KAAK,KAAK;AAAA,EACpB,CAAC;AACH;;;ADZO,IAAM,qBAAqB,CAChC,SACA,kBACuB,UAAU,aAAa,QAAQ,CAAC,EAAE,OAAO,UAAU,QAAQ,QAAQ,MAAM;AAChG,MAAI,YAAY,SAAS,OAAO,WAAW,YAAY,OAAO,KAAK,MAAM,KAAK;AAC5E,UAAM,IAAI,YAAY,kBAAkB,uDAAuD,GAAG;AAAA,EACpG;AACA,gBAAc,KAAK;AACnB,UAAQ,OAAO,OAAO,UAAU,EAAE,GAAI,WAAW,SAAY,EAAE,OAAO,IAAI,CAAC,GAAI,GAAI,YAAY,SAAY,EAAE,QAAQ,IAAI,CAAC,EAAG,CAAC;AAC9H,SAAO;AACT,CAAC;;;AEdD,S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
33
33
  },
34
34
  "revision": "333c6a9b57576a4ab95556e201da67ed864acdf02787ce5edbd653e7beba6020",
35
- "sourceRevision": "375fa6c75837bfa8ca23980d1d117e381a64ff823371f84ddb4e02c8c4b879db",
35
+ "sourceRevision": "6c3246a05b9b6ddc46373f88bca9113a2b1705487b4de41711be7f5ccb5617f3",
36
36
  "server": "server/index.js",
37
37
  "executor": "executor/index.mjs",
38
38
  "exports": {
@@ -100,8 +100,8 @@
100
100
  ]
101
101
  }
102
102
  },
103
- "revision": "05ca6d8d04b7d78376a9726d2472099d2150a1a9e62f5999dacf88aa62a336b0",
104
- "sourceRevision": "938d5980baa92e0c773c6211d146279da316f8805559e96a169292d19c536b8c",
103
+ "revision": "3fdba8c39f30027176229901cf731b778170f0e1597c287ad94f7e48a430b5e8",
104
+ "sourceRevision": "8875b59b406fa0e663b9f69dff1f6525bff867dca5947d3e114084650393ebf2",
105
105
  "server": "server/index.js",
106
106
  "web": {
107
107
  "entry": "web/index.js",
@@ -1 +1 @@
1
- ["--background","--card","--foreground","--primary","[scrollbar-width:thin]","activate","active","activeId","activeTabId","additionalProperties","alive","alt","and","are","args","aria-expanded","aria-hidden","aria-label","aria-pressed","aria-pressed:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))]","aria-pressed:border-primary/50","artifact","as","bg-[color-mix(in_srgb,var(--background)_95%,var(--primary))]","bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))]","bg-[color-mix(in_srgb,var(--foreground)_9%,var(--background))]","bg-[color-mix(in_srgb,var(--primary)_12%,var(--background))]","bg-[color-mix(in_srgb,var(--primary)_16%,var(--background))]","bg-card","bg-destructive/8","bg-primary/12","bg-white","bin","binary","block","boolean","border","border-0","border-b","border-b-border-soft","border-border","border-border-soft","border-l","border-primary/25","border-t-0","border-x-0","break-words","button","cache","catch","cause","chat","chatDocumentFrom","className","collect","configuredPlugin","const","contains","content","contentUrl","contribution","conversations","copyClass","count","createContext","createdAt","currentColor","cx","cy","data-[status=error]:border-destructive/45","data-status","date","day","defineOperation","description","descriptor","destructive","directory","document","documentMessages","documentMessagesFrom","documents","documentsApiPrefix","documentsContracts","documentsFrom","docx","dot","download","duration-100","else","en-US","entityPresenters","entry","error","eslint-disable-next-line","export","false","fetchRunFiles","file","fileDocument","fileEntry","filePath","files","filesListing","fill","flex","flex-1","flex-col","focus-visible:border-primary/50","focus-visible:outline-2","focus-visible:outline-offset-2","focus-visible:outline-primary/55","font-bold","font-semibold","for","format","formatByExtension","formatBytes","formatFromName","formatLabels","formatOf","formatTime","from","full","function","gap-0","gap-0.5","gap-1","gap-2","gap-2.5","gap-3","gap-3.5","gap-px","gif","grid","grid-cols-[14px_26px_minmax(0,1fr)_auto]","grid-cols-[24px_minmax(0,1fr)_auto]","grid-cols-[42px_minmax(0,1fr)_auto]","grid-cols-[auto_minmax(0,1fr)_auto]","group-data-[status=error]/call:text-destructive","group-hover/entry:opacity-100","group/call","group/entry","groupBadgeClass","groups","gz","h-12","h-full","handle","handles","height","hour","hover:-translate-y-px","hover:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))]","hover:bg-[color-mix(in_srgb,var(--primary)_7%,var(--card))]","hover:bg-primary/7","hover:border-primary/50","hover:border-primary/55","hover:shadow-md","href","htm","html","icon","icon-sm","id","if","image","import","in","input","instanceof","interface","is","isError","iso","items-center","jpeg","jpg","json","justify-center","key","kind","label","leading-[1.35]","leading-[1.65]","leading-[1.6]","length","let","library","line","lineCount","lines","list-none","listing","load","loaded","loose","lucide-react","m9","markdown","matter","max-[620px]:gap-2.5","max-[620px]:grid-cols-[38px_minmax(0,1fr)_auto]","max-[620px]:h-11","max-[620px]:px-2.5","max-[620px]:py-2.5","max-[620px]:sr-only","max-[620px]:w-[38px]","max-w-full","maxLength","md","mediaType","message","messages","meta","metaClass","min-h-0","min-h-30","min-h-full","min-w-0","minLength","minimum","minute","ml-[23px]","modifiedAt","month","more","mt-0.5","mt-1.5","name","needsRunView","new","next","no-store","none","not","number","onClick","onClose","onOpen","onOpenChange","onSelect","only","opacity-0","open","order","outline","overflow-y-auto","overview","p-0","p-7","p-9","parts","path","pathArgumentsFrom","pathDocumentFrom","pathDocumentsFromMessages","pb-10","pb-4.5","pdf","per","pl-2.5","plugin","png","preview","pt-2.5","pt-5","px-2","px-2.5","px-3.5","px-[clamp(18px,4vw,54px)]","px-workspace-inset","py-2","py-2.5","py-3","py-4","quassel","quassel/events","react","react-hooks/exhaustive-deps","read","readable","readonly","ready","rebuilt","relative","render","result","resultSection","results","return","reveal","rights","role","rotate-90","round","rounded-[10px]","rounded-[9px]","rounded-full","rounded-lg","rounded-none","rounded-panel","rounded-xl","routePrefix","rpc","run","runFileContentUrl","runId","running","s","sandbox","scope","secondary","sections","sectionsFrom","selection","session","setCache","setCollapsed","setError","setListing","setModalOpen","shadow-pop","shadow-sm","showCloseButton","show_document","shown","shrink-0","size","size-3","size-7","size-8","sm","sourceClass","src","srcDoc","state","status","statusLabel","store","string","stroke","strokeLinecap","strokeLinejoin","strokeWidth","sum","svg","tabId","tabular-nums","tar","text","text-[0.62rem]","text-[0.68rem]","text-[0.72rem]","text-[0.76rem]","text-[0.79rem]","text-[0.7rem]","text-[0.82rem]","text-[0.84rem]","text-[0.85rem]","text-[12px]","text-[13.5px]","text-[13px]","text-foreground","text-left","text-muted-foreground","text-primary","text-sm","textual","than","the","these","this","throw","timer","title","titleClass","to","toggle","tool","toolName","toolPresenters","tracking-[0.02em]","tracking-[0.05em]","transition-[background-color,border-color,box-shadow,transform]","transition-colors","transition-opacity","transition-transform","truncate","truncated","try","type","typebox","typeof","undefined","unknown","uppercase","url","useDocumentContent","useRunFiles","useRunFilesContext","useState","value","variant","view","viewBox","void","w-[42px]","w-[min(100%,620px)]","w-[min(1080px,calc(100%-2*clamp(16px,5vw,72px)))]","w-full","webPlugin","webp","whitespace-pre-wrap","width","workspaceTabs","xlsx","xml","yet","zip"]
1
+ ["--background","--card","--foreground","--primary","[scrollbar-width:thin]","activate","active","activeId","activeTabId","additionalProperties","alive","alt","and","are","args","aria-expanded","aria-hidden","aria-label","aria-pressed","aria-pressed:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))]","aria-pressed:border-primary/50","artifact","as","bg-[color-mix(in_srgb,var(--background)_95%,var(--primary))]","bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))]","bg-[color-mix(in_srgb,var(--foreground)_9%,var(--background))]","bg-[color-mix(in_srgb,var(--primary)_12%,var(--background))]","bg-[color-mix(in_srgb,var(--primary)_16%,var(--background))]","bg-card","bg-destructive/8","bg-primary/12","bg-white","bin","binary","block","boolean","border","border-0","border-b","border-b-border-soft","border-border","border-border-soft","border-l","border-primary/25","border-t-0","border-x-0","break-words","button","cache","catch","cause","chat","chatDocumentFrom","className","collect","configuredPlugin","const","contains","content","contentUrl","contribution","conversations","copyClass","count","createContext","createdAt","currentColor","cx","cy","data-[status=error]:border-destructive/45","data-status","date","day","defineOperation","description","descriptor","destructive","directory","document","documentMessages","documentMessagesFrom","documents","documentsApiPrefix","documentsContracts","documentsFrom","docx","dot","download","duration-100","else","entityPresenters","entry","error","eslint-disable-next-line","export","false","fetchRunFiles","file","fileDocument","fileEntry","filePath","files","filesListing","fill","flex","flex-1","flex-col","focus-visible:border-primary/50","focus-visible:outline-2","focus-visible:outline-offset-2","focus-visible:outline-primary/55","font-bold","font-semibold","for","format","formatByExtension","formatBytes","formatFromName","formatLabels","formatOf","formatTime","from","full","function","gap-0","gap-0.5","gap-1","gap-2","gap-2.5","gap-3","gap-3.5","gap-px","gif","grid","grid-cols-[14px_26px_minmax(0,1fr)_auto]","grid-cols-[24px_minmax(0,1fr)_auto]","grid-cols-[42px_minmax(0,1fr)_auto]","grid-cols-[auto_minmax(0,1fr)_auto]","group-data-[status=error]/call:text-destructive","group-hover/entry:opacity-100","group/call","group/entry","groupBadgeClass","groups","gz","h-12","h-full","handle","handles","height","hour","hover:-translate-y-px","hover:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))]","hover:bg-[color-mix(in_srgb,var(--primary)_7%,var(--card))]","hover:bg-primary/7","hover:border-primary/50","hover:border-primary/55","hover:shadow-md","href","htm","html","icon","icon-sm","id","if","image","import","in","input","instanceof","interface","is","isError","iso","items-center","jpeg","jpg","json","justify-center","key","kind","label","leading-[1.35]","leading-[1.65]","leading-[1.6]","length","let","library","line","lineCount","lines","list-none","listing","load","loaded","loose","lucide-react","m9","markdown","matter","max-[620px]:gap-2.5","max-[620px]:grid-cols-[38px_minmax(0,1fr)_auto]","max-[620px]:h-11","max-[620px]:px-2.5","max-[620px]:py-2.5","max-[620px]:sr-only","max-[620px]:w-[38px]","max-w-full","maxLength","md","mediaType","message","messages","meta","metaClass","min-h-0","min-h-30","min-h-full","min-w-0","minLength","minimum","minute","ml-[23px]","modifiedAt","month","more","mt-0.5","mt-1.5","name","needsRunView","new","next","no-store","none","not","number","onClick","onClose","onOpen","onOpenChange","onSelect","only","opacity-0","open","order","outline","overflow-y-auto","overview","p-0","p-7","p-9","parts","path","pathArgumentsFrom","pathDocumentFrom","pathDocumentsFromMessages","pb-10","pb-4.5","pdf","per","pl-2.5","plugin","png","preview","pt-2.5","pt-5","px-2","px-2.5","px-3.5","px-[clamp(18px,4vw,54px)]","px-workspace-inset","py-2","py-2.5","py-3","py-4","quassel","quassel/events","react","react-hooks/exhaustive-deps","read","readable","readonly","ready","rebuilt","relative","render","result","resultSection","results","return","reveal","rights","role","rotate-90","round","rounded-[10px]","rounded-[9px]","rounded-full","rounded-lg","rounded-none","rounded-panel","rounded-xl","routePrefix","rpc","run","runFileContentUrl","runId","running","s","sandbox","scope","secondary","sections","sectionsFrom","selection","session","setCache","setCollapsed","setError","setListing","setModalOpen","shadow-pop","shadow-sm","showCloseButton","show_document","shown","shrink-0","size","size-3","size-7","size-8","sm","sourceClass","src","srcDoc","state","status","statusLabel","store","string","stroke","strokeLinecap","strokeLinejoin","strokeWidth","sum","svg","tabId","tabular-nums","tar","text","text-[0.62rem]","text-[0.68rem]","text-[0.72rem]","text-[0.76rem]","text-[0.79rem]","text-[0.7rem]","text-[0.82rem]","text-[0.84rem]","text-[0.85rem]","text-[12px]","text-[13.5px]","text-[13px]","text-foreground","text-left","text-muted-foreground","text-primary","text-sm","textual","than","the","these","this","throw","timer","title","titleClass","to","toggle","tool","toolName","toolPresenters","tracking-[0.02em]","tracking-[0.05em]","transition-[background-color,border-color,box-shadow,transform]","transition-colors","transition-opacity","transition-transform","truncate","truncated","try","type","typebox","typeof","undefined","unknown","uppercase","url","useDocumentContent","useRunFiles","useRunFilesContext","useState","value","variant","view","viewBox","void","w-[42px]","w-[min(100%,620px)]","w-[min(1080px,calc(100%-2*clamp(16px,5vw,72px)))]","w-full","webPlugin","webp","whitespace-pre-wrap","width","workspaceTabs","xlsx","xml","yet","zip"]
@@ -1,4 +1,4 @@
1
- var u=(e,a)=>{let r=globalThis.__ragentsHostModules?.[e];if(r===void 0)throw new Error(`The host does not provide ${e}`);if(!(a in r))throw new Error(`The host does not provide ${a} from ${e}; the bundle was built against a newer host`);return r[a]};var D=u("react","createContext");var S=u("react","createElement");var B=u("react","forwardRef");var X=u("react","useCallback");var M=u("react","useContext");var P=u("react","useEffect");var C=u("react","useMemo");var g=u("react","useState");var ne=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function ce(e,a,r=[]){if(a==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:ne(e),size:24,node:a,...r.length>0?{aliases:r}:{}}}var pe=e=>{let a="",r=!1;for(let o of e){if(o==="-"||o==="_"||o<=" "){r=a.length>0;continue}a.length===0?a+=o.toLowerCase():a+=r?o.toUpperCase():o,r=!1}return a};var me=e=>{let a=pe(e);return a.charAt(0).toUpperCase()+a.slice(1)};var F=(...e)=>e.filter((a,r,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===r).join(" ").trim();var h={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function K(e){return e!=null}function Le(e,a={}){let r=a.attributeNames??{},o=m=>r[m]??m,d=e.size??e.width??h.width,l=e.size??e.height??h.height,f=e.aliases?.filter(m=>typeof m=="string"&&m.trim()!=="").map(m=>`lucide-${m}`)??[],n=[...e.name?[`lucide-${e.name}`]:[],...f],L=a.className?.split(" ").filter(Boolean)??[],c=a.includeDefaultClasses===!1?F(...L):F("lucide",...n,...L),x=a.absoluteStrokeWidth?Number(a.strokeWidth??h["stroke-width"])*Number(e.size??e.width??h.width)/Number(a.size??a.width??h.width):a.strokeWidth??h["stroke-width"];return["svg",{...Object.entries(h).reduce((m,[p,w])=>(m[o(p)]=w,m),{}),..."color"in a&&a.color&&{[o("stroke")]:a.color},..."size"in a&&K(a.size)&&{[o("width")]:a.size,[o("height")]:a.size},..."width"in a&&K(a.width)&&{[o("width")]:a.width},..."height"in a&&K(a.height)&&{[o("height")]:a.height},[o("stroke-width")]:x,...c&&{[o("class")]:c},[o("viewBox")]:`0 0 ${d} ${l}`,...a.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in a&&a.attributes},e.node.map(m=>{let[p,w,E]=m,G=a.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...w}:w;return E?[p,G,E]:[p,G]})]}function xe(e,a={}){return Le(e,{...a,attributeNames:{...a.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var Ie=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var je=D({});var Ce=()=>M(je);var ge=B(({color:e,size:a,width:r,height:o,strokeWidth:d,absoluteStrokeWidth:l,nonScalingStroke:f,className:n="",children:L,iconNode:c=[],icon:x={node:c,aliases:[],size:24},...s},m)=>{let{size:p=24,strokeWidth:w=2,absoluteStrokeWidth:E=!1,nonScalingStroke:G=!1,color:Ve="currentColor",className:Ne=""}=Ce()??{},ze=!!L||Ie(s),[Xe,Ke,Ze=[]]=xe(x,{color:e??Ve,width:r??a??p,height:o??a??p,strokeWidth:d??w,absoluteStrokeWidth:l??E,nonScalingStroke:f??G,className:F(Ne,n),hasA11yProp:ze,attributes:s});return S(Xe,{ref:m,...Ke},[...Ze.map(([_e,Qe])=>S(_e,Qe)),...Array.isArray(L)?L:[L]])});function W(e,a=[],r=[]){let o=typeof e=="string"?ce(e,a,r):e,d=B(({className:l,...f},n)=>S(ge,{ref:n,icon:o,className:l,...f}));return o.name&&(d.displayName=me(o.name)),d}var he={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};he.node;var y=W(he);var Se={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Se.node;var b=W(Se);var Z=u("@ragents/web/ui","Alert");var R=u("@ragents/web/ui","Badge");var A=u("@ragents/web/ui","Button");var _=u("@ragents/web/ui","Dialog");var Q=u("@ragents/web/ui","DialogContent");var j=u("@ragents/web/ui","DialogTitle");var T=u("@ragents/web/ui","Empty");var J=u("@ragents/web/ui","EmptyContent");var V=u("@ragents/web/ui","EmptyDescription");var q=u("@ragents/web/ui","EmptyHeader");var v=u("@ragents/web/ui","EmptyMedia");var U=u("@ragents/web/ui","EmptyTitle");var N=u("@ragents/web/ui","Spinner");var $=u("quassel","Markdown");var z=u("@ragents/web/lib/format","formatBytes");var Y=u("@ragents/web/SourceCode","SourceCode");var O=u("react/jsx-runtime","Fragment");var t=u("react/jsx-runtime","jsx");var i=u("react/jsx-runtime","jsxs");var ke="grid min-w-0 gap-px",Je="truncate text-[0.82rem] font-semibold",we="text-[0.68rem] text-muted-foreground tabular-nums",$e="min-w-0 p-0 text-[12px] whitespace-pre-wrap break-words",ee="flex size-7 items-center justify-center rounded-[9px] text-[0.62rem] font-bold tracking-[0.02em]",ae={markdown:"Markdown",text:"Text",html:"HTML",image:"Image",binary:"File"},Ye={".md":"markdown",".markdown":"markdown",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".pdf":"binary",".zip":"binary",".gz":"binary",".tar":"binary",".xlsx":"binary",".docx":"binary",".bin":"binary"},te=e=>{let a=e.lastIndexOf(".");return a<0?"text":Ye[e.slice(a).toLowerCase()]??"text"},Pe=e=>e.includes("html")?"html":e.includes("markdown")?"markdown":e.startsWith("image/")?"image":e.startsWith("text/")||e.includes("json")||e.includes("xml")?"text":"binary",Ae=e=>{let a=new Date(e);return Number.isNaN(a.getTime())?e:a.toLocaleString("en-US",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})},De=(e,a={})=>[...new Map([...Object.values(a).flat(),...e].filter(r=>r.tool?.name==="show_document").map(r=>[r.tool.id,r])).values()],oe=e=>e.flatMap(a=>{let r=a.tool;if(r?.name!=="show_document")return[];try{let o=JSON.parse(r.arguments);if(typeof o.title!="string"||typeof o.content!="string")return[];let d=o.format==="text"||o.format==="html"?o.format:"markdown";return[{id:r.id,title:o.title,content:o.content,format:d}]}catch{return[]}}),Be=e=>{let[a,r]=g({}),o=e?.format==="markdown"||e?.format==="text"||e?.format==="html",d=e?.content===void 0&&o?e?.contentUrl:void 0;if(P(()=>{if(!d||a[d])return;let l=!0;return fetch(d,{cache:"no-store"}).then(async f=>{if(!f.ok)throw new Error(`Status ${f.status}`);return f.text()}).then(f=>l&&r(n=>({...n,[d]:{text:f}}))).catch(f=>l&&r(n=>({...n,[d]:{error:f instanceof Error?f.message:String(f)}}))),()=>{l=!1}},[d,a]),!!e)return e.content!==void 0?{text:e.content}:o?d?a[d]:void 0:{text:""}};function Me({active:e,document:a,onOpen:r,status:o}){let d=C(()=>a.content?a.content.split(/\r\n|\r|\n/).length:0,[a.content]),l=o==="error"?"Error":o==="running"?"Opening":e?"Opened":"Open";return i("button",{"aria-pressed":e,className:"group/call grid w-[min(100%,620px)] grid-cols-[42px_minmax(0,1fr)_auto] items-center gap-3 rounded-xl border border-border bg-[color-mix(in_srgb,var(--background)_95%,var(--primary))] px-3.5 py-3 text-left shadow-sm transition-[background-color,border-color,box-shadow,transform] duration-100 hover:-translate-y-px hover:border-primary/50 hover:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))] hover:shadow-md focus-visible:border-primary/50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary/55 aria-pressed:border-primary/50 aria-pressed:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))] data-[status=error]:border-destructive/45 max-[620px]:grid-cols-[38px_minmax(0,1fr)_auto] max-[620px]:gap-2.5 max-[620px]:px-2.5 max-[620px]:py-2.5","data-status":o,onClick:r,type:"button",children:[t("span",{className:"flex h-12 w-[42px] items-center justify-center rounded-lg border border-primary/25 bg-primary/12 text-primary group-data-[status=error]/call:text-destructive max-[620px]:h-11 max-[620px]:w-[38px]",children:t(H,{size:22})}),i("span",{className:"flex min-w-0 flex-col gap-0.5",children:[t("span",{className:"text-[0.62rem] font-semibold tracking-[0.05em] text-primary uppercase",children:"Document"}),t("strong",{className:"truncate text-[0.84rem] leading-[1.35]",title:a.title,children:a.title}),i("span",{className:"text-[0.7rem] leading-[1.35] text-muted-foreground",children:[ae[a.format],", ",d.toLocaleString("en-US")," ",d===1?"line":"lines"]})]}),i("span",{className:"flex items-center gap-1 text-[0.7rem] font-semibold text-primary group-data-[status=error]/call:text-destructive",children:[t("span",{className:"max-[620px]:sr-only",children:l}),o==="running"?t(N,{className:"size-3"}):o==="error"?t(Te,{}):t(Re,{})]})]})}function Fe({document:e,loaded:a}){return e.format==="image"&&e.contentUrl?t("img",{alt:e.title,className:"block max-w-full rounded-lg border border-border",src:e.contentUrl}):e.format==="binary"&&e.contentUrl?i(T,{className:"min-h-30 gap-2 p-7",children:[i(q,{children:[t(v,{children:t(H,{})}),t(U,{children:"No preview for this format"})]}),t(J,{children:t(A,{render:t("a",{download:e.title,href:e.contentUrl}),size:"sm",variant:"outline",children:"Download"})})]}):a?"error"in a?t(T,{className:"min-h-30 gap-2 p-7",children:i(q,{children:[t(v,{children:t(Te,{})}),t(U,{children:"Content not readable"}),t(V,{children:a.error})]})}):e.format==="html"?t("iframe",{className:"h-full min-h-full w-full border-0 bg-white",sandbox:"",srcDoc:a.text,title:e.title}):e.format==="text"?t(Y,{className:$e,content:a.text,path:e.title}):t($,{text:a.text}):i("div",{className:"flex items-center justify-center gap-2.5 p-9 text-[0.76rem] text-muted-foreground",children:[t(N,{className:"size-3"}),t("span",{children:"Loading"})]})}function ye({document:e}){let a=[ae[e.format],e.size!==void 0?z(e.size):void 0,e.createdAt?Ae(e.createdAt):void 0,e.meta].filter(Boolean);return i(O,{children:[t("strong",{className:Je,title:e.title,children:e.title}),t("span",{className:we,children:a.join(" \xB7 ")})]})}function ea({document:e,onClose:a}){let r=Be(e);return t(_,{open:!0,onOpenChange:o=>{o||a()},children:i(Q,{className:"w-[min(1080px,calc(100%-2*clamp(16px,5vw,72px)))] gap-0 rounded-panel border border-border bg-card p-0 shadow-pop",scope:"run",showCloseButton:!1,size:"full",children:[i("header",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 border-b border-border px-3.5 py-3",children:[t("span",{className:"flex size-8 items-center justify-center rounded-[10px] bg-[color-mix(in_srgb,var(--primary)_12%,var(--background))] text-primary",children:t(H,{size:20})}),t(j,{className:ke,render:t("span",{}),children:t(ye,{document:e})}),t(A,{"aria-label":"Close",className:"rounded-full",onClick:a,size:"icon",title:"Close",variant:"outline",children:t(b,{})})]}),t("div",{className:"min-h-0 flex-1 overflow-y-auto px-[clamp(18px,4vw,54px)] pt-5 pb-10 text-[13.5px] leading-[1.65]",children:t(Fe,{document:e,loaded:r})})]})})}function be({activeId:e,sections:a,truncated:r,onSelect:o}){let d=a.flatMap(s=>s.documents).find(s=>s.id===e),l=Be(d),[f,n]=g(!1),[L,c]=g(()=>new Set),x=X(s=>{c(m=>{let p=new Set(m);return p.has(s)?p.delete(s):p.add(s),p})},[]);return P(()=>{d||n(!1)},[d]),a.every(s=>s.documents.length===0)?t(T,{className:"h-full gap-2 p-7",children:i(q,{children:[t(v,{children:t(H,{})}),t(U,{children:"No documents yet"}),t(V,{children:"Files from the run's store, results, and documents shown in chat collect here."})]})}):d?i("div",{className:"flex h-full min-h-0 flex-col",children:[i("header",{className:"grid shrink-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 border-b border-border-soft px-workspace-inset py-2.5",children:[t(A,{"aria-label":"Back to overview",onClick:()=>o(void 0),size:"icon-sm",title:"Back to overview",variant:"outline",children:t(y,{})}),t("span",{className:ke,children:t(ye,{document:d})}),t(A,{onClick:()=>n(!0),size:"sm",variant:"outline",children:"Large"})]}),t("div",{className:"min-h-0 flex-1 overflow-y-auto px-workspace-inset py-4 text-[13px] leading-[1.6]",children:t(Fe,{document:d,loaded:l})}),f&&t(ea,{document:d,onClose:()=>n(!1)})]}):i("div",{className:"flex h-full flex-col gap-3.5 overflow-y-auto px-workspace-inset pt-2.5 pb-4.5 [scrollbar-width:thin]",children:[a.filter(s=>s.documents.length>0).map(s=>{let m=!L.has(s.id);return i("section",{children:[i("button",{"aria-expanded":m,className:"grid w-full grid-cols-[14px_26px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg px-2 py-2 text-left hover:bg-primary/7",onClick:()=>x(s.id),type:"button",children:[t("span",{"aria-hidden":!0,className:`flex text-muted-foreground transition-transform duration-150${m?" rotate-90":""}`,children:t(aa,{})}),s.kind==="store"&&t("span",{"aria-hidden":!0,className:`${ee} bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))] text-[0.85rem] text-foreground`,children:"#"}),s.kind==="results"&&t("span",{"aria-hidden":!0,className:`${ee} bg-[color-mix(in_srgb,var(--primary)_16%,var(--background))] text-primary`,children:t(oa,{})}),s.kind==="chat"&&t("span",{"aria-hidden":!0,className:`${ee} bg-[color-mix(in_srgb,var(--foreground)_9%,var(--background))] text-muted-foreground`,children:t(ta,{})}),t("span",{className:"truncate text-sm font-semibold",title:s.label,children:s.label}),t(R,{className:"tabular-nums",variant:"secondary",children:s.documents.length})]}),m&&t("div",{className:"ml-[23px] border-l border-border-soft pl-2.5",children:t("ul",{className:"mt-0.5 list-none",children:s.documents.map(p=>t("li",{children:i("button",{className:"group/entry mt-1.5 grid w-full grid-cols-[24px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg border border-border bg-card px-2.5 py-2.5 text-left transition-colors duration-100 hover:border-primary/55 hover:bg-[color-mix(in_srgb,var(--primary)_7%,var(--card))]",onClick:()=>o(p.id),type:"button",children:[t("span",{className:"flex text-primary",children:t(H,{size:18})}),i("span",{className:"grid min-w-0 gap-0.5",children:[t("strong",{className:"truncate text-[0.79rem] font-semibold",title:p.title,children:p.title}),t("small",{className:we,children:[ae[p.format],p.size!==void 0?z(p.size):void 0,p.createdAt?Ae(p.createdAt):void 0,p.meta].filter(Boolean).join(" \xB7 ")})]}),t("span",{"aria-hidden":!0,className:"flex text-muted-foreground opacity-0 transition-opacity duration-100 group-hover/entry:opacity-100",children:t(Re,{})})]})},p.id))})})]},s.id)}),r&&t("p",{className:"text-[0.72rem] text-muted-foreground",children:"The store contains more files than are shown here."})]})}function H({size:e=28}){return i("svg",{"aria-hidden":!0,fill:"none",height:e,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",viewBox:"0 0 24 24",width:e,children:[t("path",{d:"M6 3h8l4 4v14H6z"}),t("path",{d:"M14 3v5h4M9 13h6M9 17h4"})]})}function Re(){return t("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:t("path",{d:"m9 18 6-6-6-6"})})}function aa(){return t("svg",{"aria-hidden":!0,fill:"none",height:"12",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"12",children:t("path",{d:"m9 18 6-6-6-6"})})}function ta(){return t("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:t("path",{d:"M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.4A8 8 0 1 1 21 12z"})})}function oa(){return t("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:t("path",{d:"M20 6 9 17l-5-5"})})}function Te(){return i("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7v6M12 17h.01"})]})}var ue=u("@ragents/web/rpc","rpc");var I=u("typebox","Type");var re=u("@ragents/engine/src/rpc/contract","defineOperation");var qe=I.Object({path:I.String({minLength:1}),size:I.Integer({minimum:0}),modifiedAt:I.String({minLength:1})},{additionalProperties:!1}),ua=I.Object({groups:I.Array(I.Object({directory:I.String({minLength:1}),files:I.Array(qe)},{additionalProperties:!1})),loose:I.Array(qe),truncated:I.Boolean()},{additionalProperties:!1}),ve={files:re({id:"ragents.documents.files",description:"A run's file store as groups and loose files. Right: runs.read.",rights:["runs.read"],input:I.Object({runId:I.String({minLength:1,maxLength:64,description:"Run id"})},{additionalProperties:!1}),result:ua})};var de=(e,a,r)=>`${e}/runs/${encodeURIComponent(a)}/files/content?path=${encodeURIComponent(r)}`,Ue=e=>ue.call(ve.files,{runId:e});var le=u("@ragents/web/run-view","runArtifactContentUrl");var fe=u("@ragents/web/run-view","runViewFrom");var se=u("@ragents/web/PluginRegistry","pluginRoutePrefixFrom");var ra="ragents.documents",k="ragents.documents.library",da=e=>{if(e.name==="show_document")try{let a=JSON.parse(e.arguments);return typeof a.title!="string"||typeof a.path!="string"||typeof a.content=="string"?void 0:{title:a.title,path:a.path,...typeof a.format=="string"?{format:a.format}:{}}}catch{return}},Ee=(e,a,r)=>{let o=da(e);if(!o)return;let d=o.format==="markdown"||o.format==="text"||o.format==="html"?o.format:te(o.path);return{id:e.id,title:o.title,format:d,contentUrl:de(a,r,o.path)}},Ge=(e,a,r)=>oe([{key:e.id,role:"tool",text:e.name,tool:e}])[0]??Ee(e,a,r),la=(e,a,r)=>e.flatMap(o=>{let d=o.tool;if(!d)return[];let l=Ee(d,a,r);return l?[l]:[]}),We=D(void 0),Oe=()=>{let e=M(We);if(!e)throw new Error("Documents plugin is not active");return e},fa=e=>{let[a,r]=g(),[o,d]=g(),l=e.session.id;return P(()=>{let f=!0,n=()=>{Ue(l).then(c=>{f&&(r(c),d(void 0))}).catch(c=>f&&d(c instanceof Error?c.message:String(c)))};if(n(),!e.running)return()=>{f=!1};let L=setInterval(n,5e3);return()=>{f=!1,clearInterval(L)}},[l,e.running]),C(()=>({listing:a,error:o}),[a,o])};function sa({children:e,session:a}){let r=fa(a);return t(We.Provider,{value:r,children:e})}var ia=(e,a)=>{let r=new Map(a.actors.map(o=>[o.id,o.handle]));return{id:"results",label:"Results",kind:"results",documents:a.artifacts.map(o=>{let d=r.get(o.createdBy);return{id:o.id,title:o.title,format:Pe(o.mediaType),contentUrl:le(e,o.id),createdAt:o.createdAt,size:o.size,...d?{meta:`@${d}`}:{}}})}},He=(e,a,r)=>{let o=a.session.id,d=fe(a.runView),l=(c,x)=>{let s=c?`${c}/${x.path}`:x.path;return{id:`file:${s}`,title:x.path,format:te(x.path),contentUrl:`${de(e,o,s)}&v=${encodeURIComponent(x.modifiedAt)}`,createdAt:x.modifiedAt,size:x.size}},f=[...(r?.groups??[]).map(c=>({id:`store/${c.directory}`,label:c.directory,kind:"store",documents:c.files.map(x=>l(c.directory,x))})),...r&&r.loose.length>0?[{id:"store",label:"Store",kind:"store",documents:r.loose.map(c=>l(void 0,c))}]:[],...d&&d.artifacts.length>0?[ia(o,d)]:[]],n=De(a.messages,a.actorConversations),L=[...oe(n),...la(n,e,a.session.id)];return L.length>0&&f.push({id:"chat",label:"Shown in chat",kind:"chat",documents:L}),{sections:f,truncated:r?.truncated??!1}},na=e=>{function a({navigation:o,selection:d,session:l}){let{listing:f,error:n}=Oe(),{sections:L,truncated:c}=C(()=>He(e,l,f),[l.messages,l.actorConversations,l.runView,l.session.id,f]);return i(O,{children:[n&&t(Z,{className:"shrink-0 rounded-none border-x-0 border-t-0 border-b-border-soft bg-destructive/8 px-2.5 py-2 text-[0.68rem]",variant:"destructive",children:n}),t(be,{activeId:typeof d=="string"?d:void 0,sections:L,truncated:c,onSelect:x=>o.openTab(k,x??null)})]})}function r({session:o}){let{listing:d}=Oe(),{sections:l}=C(()=>He(e,o,d),[o.messages,o.actorConversations,o.runView,o.session.id,d]),f=l.reduce((n,L)=>n+L.documents.length,0);return f>0?t(R,{className:"tabular-nums",variant:"secondary",children:f}):null}return{DocumentsPanelContribution:a,DocumentsBadge:r}};function ca({navigation:e,session:a,tool:r,routePrefix:o}){let d=Ge(r,o,a.session.id);if(!d)return null;let l=r.isError?"error":r.result===void 0?"running":"ready";return t(Me,{active:e.activeTabId===k&&e.selectionFor(k)===d.id,document:d,onOpen:()=>e.openTab(k,d.id),status:l})}function pa(){return t("svg",{"aria-hidden":!0,fill:"none",height:"15",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.7",viewBox:"0 0 24 24",width:"15",children:t("path",{d:"M6 3h8l4 4v14H6zM14 3v5h4M9 13h6M9 17h4"})})}var ma=(e,a)=>{let{DocumentsPanelContribution:r,DocumentsBadge:o}=na(a);return{...e,needsRunView:!0,SessionProvider:sa,workspaceTabs:[{id:k,label:"Documents",order:200,Icon:pa,Panel:r,Badge:o}],toolPresenters:[{toolName:"show_document",Inline:d=>t(ca,{...d,routePrefix:a}),reveal:(d,l)=>Ge(d,a,l.session.id)?{tabId:k,selection:d.id}:void 0}],entityPresenters:[{reveal:d=>d.type==="artifact"?{tabId:k,selection:d.id}:void 0}]}},ie={id:ra},gu={...ie,activate:e=>ma(ie,se(ie.id,e))};export{ra as DOCUMENTS_PLUGIN_ID,k as DOCUMENTS_TAB_ID,gu as webPlugin};
1
+ var u=(e,a)=>{let r=globalThis.__ragentsHostModules?.[e];if(r===void 0)throw new Error(`The host does not provide ${e}`);if(!(a in r))throw new Error(`The host does not provide ${a} from ${e}; the bundle was built against a newer host`);return r[a]};var D=u("react","createContext");var S=u("react","createElement");var B=u("react","forwardRef");var X=u("react","useCallback");var M=u("react","useContext");var P=u("react","useEffect");var C=u("react","useMemo");var g=u("react","useState");var ne=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function ce(e,a,r=[]){if(a==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:ne(e),size:24,node:a,...r.length>0?{aliases:r}:{}}}var pe=e=>{let a="",r=!1;for(let o of e){if(o==="-"||o==="_"||o<=" "){r=a.length>0;continue}a.length===0?a+=o.toLowerCase():a+=r?o.toUpperCase():o,r=!1}return a};var me=e=>{let a=pe(e);return a.charAt(0).toUpperCase()+a.slice(1)};var F=(...e)=>e.filter((a,r,o)=>!!a&&a.trim()!==""&&o.indexOf(a)===r).join(" ").trim();var h={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function K(e){return e!=null}function Le(e,a={}){let r=a.attributeNames??{},o=m=>r[m]??m,d=e.size??e.width??h.width,l=e.size??e.height??h.height,f=e.aliases?.filter(m=>typeof m=="string"&&m.trim()!=="").map(m=>`lucide-${m}`)??[],n=[...e.name?[`lucide-${e.name}`]:[],...f],L=a.className?.split(" ").filter(Boolean)??[],c=a.includeDefaultClasses===!1?F(...L):F("lucide",...n,...L),x=a.absoluteStrokeWidth?Number(a.strokeWidth??h["stroke-width"])*Number(e.size??e.width??h.width)/Number(a.size??a.width??h.width):a.strokeWidth??h["stroke-width"];return["svg",{...Object.entries(h).reduce((m,[p,w])=>(m[o(p)]=w,m),{}),..."color"in a&&a.color&&{[o("stroke")]:a.color},..."size"in a&&K(a.size)&&{[o("width")]:a.size,[o("height")]:a.size},..."width"in a&&K(a.width)&&{[o("width")]:a.width},..."height"in a&&K(a.height)&&{[o("height")]:a.height},[o("stroke-width")]:x,...c&&{[o("class")]:c},[o("viewBox")]:`0 0 ${d} ${l}`,...a.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in a&&a.attributes},e.node.map(m=>{let[p,w,E]=m,G=a.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...w}:w;return E?[p,G,E]:[p,G]})]}function xe(e,a={}){return Le(e,{...a,attributeNames:{...a.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var Ie=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};var je=D({});var Ce=()=>M(je);var ge=B(({color:e,size:a,width:r,height:o,strokeWidth:d,absoluteStrokeWidth:l,nonScalingStroke:f,className:n="",children:L,iconNode:c=[],icon:x={node:c,aliases:[],size:24},...s},m)=>{let{size:p=24,strokeWidth:w=2,absoluteStrokeWidth:E=!1,nonScalingStroke:G=!1,color:Ve="currentColor",className:Ne=""}=Ce()??{},ze=!!L||Ie(s),[Xe,Ke,Ze=[]]=xe(x,{color:e??Ve,width:r??a??p,height:o??a??p,strokeWidth:d??w,absoluteStrokeWidth:l??E,nonScalingStroke:f??G,className:F(Ne,n),hasA11yProp:ze,attributes:s});return S(Xe,{ref:m,...Ke},[...Ze.map(([_e,Qe])=>S(_e,Qe)),...Array.isArray(L)?L:[L]])});function W(e,a=[],r=[]){let o=typeof e=="string"?ce(e,a,r):e,d=B(({className:l,...f},n)=>S(ge,{ref:n,icon:o,className:l,...f}));return o.name&&(d.displayName=me(o.name)),d}var he={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};he.node;var y=W(he);var Se={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Se.node;var b=W(Se);var Z=u("@ragents/web/ui","Alert");var R=u("@ragents/web/ui","Badge");var A=u("@ragents/web/ui","Button");var _=u("@ragents/web/ui","Dialog");var Q=u("@ragents/web/ui","DialogContent");var j=u("@ragents/web/ui","DialogTitle");var T=u("@ragents/web/ui","Empty");var J=u("@ragents/web/ui","EmptyContent");var V=u("@ragents/web/ui","EmptyDescription");var q=u("@ragents/web/ui","EmptyHeader");var v=u("@ragents/web/ui","EmptyMedia");var U=u("@ragents/web/ui","EmptyTitle");var N=u("@ragents/web/ui","Spinner");var $=u("quassel","Markdown");var z=u("@ragents/web/lib/format","formatBytes");var Y=u("@ragents/web/SourceCode","SourceCode");var O=u("react/jsx-runtime","Fragment");var t=u("react/jsx-runtime","jsx");var i=u("react/jsx-runtime","jsxs");var ke="grid min-w-0 gap-px",Je="truncate text-[0.82rem] font-semibold",we="text-[0.68rem] text-muted-foreground tabular-nums",$e="min-w-0 p-0 text-[12px] whitespace-pre-wrap break-words",ee="flex size-7 items-center justify-center rounded-[9px] text-[0.62rem] font-bold tracking-[0.02em]",ae={markdown:"Markdown",text:"Text",html:"HTML",image:"Image",binary:"File"},Ye={".md":"markdown",".markdown":"markdown",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".pdf":"binary",".zip":"binary",".gz":"binary",".tar":"binary",".xlsx":"binary",".docx":"binary",".bin":"binary"},te=e=>{let a=e.lastIndexOf(".");return a<0?"text":Ye[e.slice(a).toLowerCase()]??"text"},Pe=e=>e.includes("html")?"html":e.includes("markdown")?"markdown":e.startsWith("image/")?"image":e.startsWith("text/")||e.includes("json")||e.includes("xml")?"text":"binary",Ae=e=>{let a=new Date(e);return Number.isNaN(a.getTime())?e:a.toLocaleString(void 0,{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})},De=(e,a={})=>[...new Map([...Object.values(a).flat(),...e].filter(r=>r.tool?.name==="show_document").map(r=>[r.tool.id,r])).values()],oe=e=>e.flatMap(a=>{let r=a.tool;if(r?.name!=="show_document")return[];try{let o=JSON.parse(r.arguments);if(typeof o.title!="string"||typeof o.content!="string")return[];let d=o.format==="text"||o.format==="html"?o.format:"markdown";return[{id:r.id,title:o.title,content:o.content,format:d}]}catch{return[]}}),Be=e=>{let[a,r]=g({}),o=e?.format==="markdown"||e?.format==="text"||e?.format==="html",d=e?.content===void 0&&o?e?.contentUrl:void 0;if(P(()=>{if(!d||a[d])return;let l=!0;return fetch(d,{cache:"no-store"}).then(async f=>{if(!f.ok)throw new Error(`Status ${f.status}`);return f.text()}).then(f=>l&&r(n=>({...n,[d]:{text:f}}))).catch(f=>l&&r(n=>({...n,[d]:{error:f instanceof Error?f.message:String(f)}}))),()=>{l=!1}},[d,a]),!!e)return e.content!==void 0?{text:e.content}:o?d?a[d]:void 0:{text:""}};function Me({active:e,document:a,onOpen:r,status:o}){let d=C(()=>a.content?a.content.split(/\r\n|\r|\n/).length:0,[a.content]),l=o==="error"?"Error":o==="running"?"Opening":e?"Opened":"Open";return i("button",{"aria-pressed":e,className:"group/call grid w-[min(100%,620px)] grid-cols-[42px_minmax(0,1fr)_auto] items-center gap-3 rounded-xl border border-border bg-[color-mix(in_srgb,var(--background)_95%,var(--primary))] px-3.5 py-3 text-left shadow-sm transition-[background-color,border-color,box-shadow,transform] duration-100 hover:-translate-y-px hover:border-primary/50 hover:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))] hover:shadow-md focus-visible:border-primary/50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary/55 aria-pressed:border-primary/50 aria-pressed:bg-[color-mix(in_srgb,var(--background)_91%,var(--primary))] data-[status=error]:border-destructive/45 max-[620px]:grid-cols-[38px_minmax(0,1fr)_auto] max-[620px]:gap-2.5 max-[620px]:px-2.5 max-[620px]:py-2.5","data-status":o,onClick:r,type:"button",children:[t("span",{className:"flex h-12 w-[42px] items-center justify-center rounded-lg border border-primary/25 bg-primary/12 text-primary group-data-[status=error]/call:text-destructive max-[620px]:h-11 max-[620px]:w-[38px]",children:t(H,{size:22})}),i("span",{className:"flex min-w-0 flex-col gap-0.5",children:[t("span",{className:"text-[0.62rem] font-semibold tracking-[0.05em] text-primary uppercase",children:"Document"}),t("strong",{className:"truncate text-[0.84rem] leading-[1.35]",title:a.title,children:a.title}),i("span",{className:"text-[0.7rem] leading-[1.35] text-muted-foreground",children:[ae[a.format],", ",d.toLocaleString()," ",d===1?"line":"lines"]})]}),i("span",{className:"flex items-center gap-1 text-[0.7rem] font-semibold text-primary group-data-[status=error]/call:text-destructive",children:[t("span",{className:"max-[620px]:sr-only",children:l}),o==="running"?t(N,{className:"size-3"}):o==="error"?t(Te,{}):t(Re,{})]})]})}function Fe({document:e,loaded:a}){return e.format==="image"&&e.contentUrl?t("img",{alt:e.title,className:"block max-w-full rounded-lg border border-border",src:e.contentUrl}):e.format==="binary"&&e.contentUrl?i(T,{className:"min-h-30 gap-2 p-7",children:[i(q,{children:[t(v,{children:t(H,{})}),t(U,{children:"No preview for this format"})]}),t(J,{children:t(A,{render:t("a",{download:e.title,href:e.contentUrl}),size:"sm",variant:"outline",children:"Download"})})]}):a?"error"in a?t(T,{className:"min-h-30 gap-2 p-7",children:i(q,{children:[t(v,{children:t(Te,{})}),t(U,{children:"Content not readable"}),t(V,{children:a.error})]})}):e.format==="html"?t("iframe",{className:"h-full min-h-full w-full border-0 bg-white",sandbox:"",srcDoc:a.text,title:e.title}):e.format==="text"?t(Y,{className:$e,content:a.text,path:e.title}):t($,{text:a.text}):i("div",{className:"flex items-center justify-center gap-2.5 p-9 text-[0.76rem] text-muted-foreground",children:[t(N,{className:"size-3"}),t("span",{children:"Loading"})]})}function ye({document:e}){let a=[ae[e.format],e.size!==void 0?z(e.size):void 0,e.createdAt?Ae(e.createdAt):void 0,e.meta].filter(Boolean);return i(O,{children:[t("strong",{className:Je,title:e.title,children:e.title}),t("span",{className:we,children:a.join(" \xB7 ")})]})}function ea({document:e,onClose:a}){let r=Be(e);return t(_,{open:!0,onOpenChange:o=>{o||a()},children:i(Q,{className:"w-[min(1080px,calc(100%-2*clamp(16px,5vw,72px)))] gap-0 rounded-panel border border-border bg-card p-0 shadow-pop",scope:"run",showCloseButton:!1,size:"full",children:[i("header",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 border-b border-border px-3.5 py-3",children:[t("span",{className:"flex size-8 items-center justify-center rounded-[10px] bg-[color-mix(in_srgb,var(--primary)_12%,var(--background))] text-primary",children:t(H,{size:20})}),t(j,{className:ke,render:t("span",{}),children:t(ye,{document:e})}),t(A,{"aria-label":"Close",className:"rounded-full",onClick:a,size:"icon",title:"Close",variant:"outline",children:t(b,{})})]}),t("div",{className:"min-h-0 flex-1 overflow-y-auto px-[clamp(18px,4vw,54px)] pt-5 pb-10 text-[13.5px] leading-[1.65]",children:t(Fe,{document:e,loaded:r})})]})})}function be({activeId:e,sections:a,truncated:r,onSelect:o}){let d=a.flatMap(s=>s.documents).find(s=>s.id===e),l=Be(d),[f,n]=g(!1),[L,c]=g(()=>new Set),x=X(s=>{c(m=>{let p=new Set(m);return p.has(s)?p.delete(s):p.add(s),p})},[]);return P(()=>{d||n(!1)},[d]),a.every(s=>s.documents.length===0)?t(T,{className:"h-full gap-2 p-7",children:i(q,{children:[t(v,{children:t(H,{})}),t(U,{children:"No documents yet"}),t(V,{children:"Files from the run's store, results, and documents shown in chat collect here."})]})}):d?i("div",{className:"flex h-full min-h-0 flex-col",children:[i("header",{className:"grid shrink-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2.5 border-b border-border-soft px-workspace-inset py-2.5",children:[t(A,{"aria-label":"Back to overview",onClick:()=>o(void 0),size:"icon-sm",title:"Back to overview",variant:"outline",children:t(y,{})}),t("span",{className:ke,children:t(ye,{document:d})}),t(A,{onClick:()=>n(!0),size:"sm",variant:"outline",children:"Large"})]}),t("div",{className:"min-h-0 flex-1 overflow-y-auto px-workspace-inset py-4 text-[13px] leading-[1.6]",children:t(Fe,{document:d,loaded:l})}),f&&t(ea,{document:d,onClose:()=>n(!1)})]}):i("div",{className:"flex h-full flex-col gap-3.5 overflow-y-auto px-workspace-inset pt-2.5 pb-4.5 [scrollbar-width:thin]",children:[a.filter(s=>s.documents.length>0).map(s=>{let m=!L.has(s.id);return i("section",{children:[i("button",{"aria-expanded":m,className:"grid w-full grid-cols-[14px_26px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg px-2 py-2 text-left hover:bg-primary/7",onClick:()=>x(s.id),type:"button",children:[t("span",{"aria-hidden":!0,className:`flex text-muted-foreground transition-transform duration-150${m?" rotate-90":""}`,children:t(aa,{})}),s.kind==="store"&&t("span",{"aria-hidden":!0,className:`${ee} bg-[color-mix(in_srgb,var(--foreground)_8%,var(--background))] text-[0.85rem] text-foreground`,children:"#"}),s.kind==="results"&&t("span",{"aria-hidden":!0,className:`${ee} bg-[color-mix(in_srgb,var(--primary)_16%,var(--background))] text-primary`,children:t(oa,{})}),s.kind==="chat"&&t("span",{"aria-hidden":!0,className:`${ee} bg-[color-mix(in_srgb,var(--foreground)_9%,var(--background))] text-muted-foreground`,children:t(ta,{})}),t("span",{className:"truncate text-sm font-semibold",title:s.label,children:s.label}),t(R,{className:"tabular-nums",variant:"secondary",children:s.documents.length})]}),m&&t("div",{className:"ml-[23px] border-l border-border-soft pl-2.5",children:t("ul",{className:"mt-0.5 list-none",children:s.documents.map(p=>t("li",{children:i("button",{className:"group/entry mt-1.5 grid w-full grid-cols-[24px_minmax(0,1fr)_auto] items-center gap-2.5 rounded-lg border border-border bg-card px-2.5 py-2.5 text-left transition-colors duration-100 hover:border-primary/55 hover:bg-[color-mix(in_srgb,var(--primary)_7%,var(--card))]",onClick:()=>o(p.id),type:"button",children:[t("span",{className:"flex text-primary",children:t(H,{size:18})}),i("span",{className:"grid min-w-0 gap-0.5",children:[t("strong",{className:"truncate text-[0.79rem] font-semibold",title:p.title,children:p.title}),t("small",{className:we,children:[ae[p.format],p.size!==void 0?z(p.size):void 0,p.createdAt?Ae(p.createdAt):void 0,p.meta].filter(Boolean).join(" \xB7 ")})]}),t("span",{"aria-hidden":!0,className:"flex text-muted-foreground opacity-0 transition-opacity duration-100 group-hover/entry:opacity-100",children:t(Re,{})})]})},p.id))})})]},s.id)}),r&&t("p",{className:"text-[0.72rem] text-muted-foreground",children:"The store contains more files than are shown here."})]})}function H({size:e=28}){return i("svg",{"aria-hidden":!0,fill:"none",height:e,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",viewBox:"0 0 24 24",width:e,children:[t("path",{d:"M6 3h8l4 4v14H6z"}),t("path",{d:"M14 3v5h4M9 13h6M9 17h4"})]})}function Re(){return t("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:t("path",{d:"m9 18 6-6-6-6"})})}function aa(){return t("svg",{"aria-hidden":!0,fill:"none",height:"12",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"12",children:t("path",{d:"m9 18 6-6-6-6"})})}function ta(){return t("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:t("path",{d:"M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.4A8 8 0 1 1 21 12z"})})}function oa(){return t("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:t("path",{d:"M20 6 9 17l-5-5"})})}function Te(){return i("svg",{"aria-hidden":!0,fill:"none",height:"14",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8",viewBox:"0 0 24 24",width:"14",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7v6M12 17h.01"})]})}var ue=u("@ragents/web/rpc","rpc");var I=u("typebox","Type");var re=u("@ragents/engine/src/rpc/contract","defineOperation");var qe=I.Object({path:I.String({minLength:1}),size:I.Integer({minimum:0}),modifiedAt:I.String({minLength:1})},{additionalProperties:!1}),ua=I.Object({groups:I.Array(I.Object({directory:I.String({minLength:1}),files:I.Array(qe)},{additionalProperties:!1})),loose:I.Array(qe),truncated:I.Boolean()},{additionalProperties:!1}),ve={files:re({id:"ragents.documents.files",description:"A run's file store as groups and loose files. Right: runs.read.",rights:["runs.read"],input:I.Object({runId:I.String({minLength:1,maxLength:64,description:"Run id"})},{additionalProperties:!1}),result:ua})};var de=(e,a,r)=>`${e}/runs/${encodeURIComponent(a)}/files/content?path=${encodeURIComponent(r)}`,Ue=e=>ue.call(ve.files,{runId:e});var le=u("@ragents/web/run-view","runArtifactContentUrl");var fe=u("@ragents/web/run-view","runViewFrom");var se=u("@ragents/web/PluginRegistry","pluginRoutePrefixFrom");var ra="ragents.documents",k="ragents.documents.library",da=e=>{if(e.name==="show_document")try{let a=JSON.parse(e.arguments);return typeof a.title!="string"||typeof a.path!="string"||typeof a.content=="string"?void 0:{title:a.title,path:a.path,...typeof a.format=="string"?{format:a.format}:{}}}catch{return}},Ee=(e,a,r)=>{let o=da(e);if(!o)return;let d=o.format==="markdown"||o.format==="text"||o.format==="html"?o.format:te(o.path);return{id:e.id,title:o.title,format:d,contentUrl:de(a,r,o.path)}},Ge=(e,a,r)=>oe([{key:e.id,role:"tool",text:e.name,tool:e}])[0]??Ee(e,a,r),la=(e,a,r)=>e.flatMap(o=>{let d=o.tool;if(!d)return[];let l=Ee(d,a,r);return l?[l]:[]}),We=D(void 0),Oe=()=>{let e=M(We);if(!e)throw new Error("Documents plugin is not active");return e},fa=e=>{let[a,r]=g(),[o,d]=g(),l=e.session.id;return P(()=>{let f=!0,n=()=>{Ue(l).then(c=>{f&&(r(c),d(void 0))}).catch(c=>f&&d(c instanceof Error?c.message:String(c)))};if(n(),!e.running)return()=>{f=!1};let L=setInterval(n,5e3);return()=>{f=!1,clearInterval(L)}},[l,e.running]),C(()=>({listing:a,error:o}),[a,o])};function sa({children:e,session:a}){let r=fa(a);return t(We.Provider,{value:r,children:e})}var ia=(e,a)=>{let r=new Map(a.actors.map(o=>[o.id,o.handle]));return{id:"results",label:"Results",kind:"results",documents:a.artifacts.map(o=>{let d=r.get(o.createdBy);return{id:o.id,title:o.title,format:Pe(o.mediaType),contentUrl:le(e,o.id),createdAt:o.createdAt,size:o.size,...d?{meta:`@${d}`}:{}}})}},He=(e,a,r)=>{let o=a.session.id,d=fe(a.runView),l=(c,x)=>{let s=c?`${c}/${x.path}`:x.path;return{id:`file:${s}`,title:x.path,format:te(x.path),contentUrl:`${de(e,o,s)}&v=${encodeURIComponent(x.modifiedAt)}`,createdAt:x.modifiedAt,size:x.size}},f=[...(r?.groups??[]).map(c=>({id:`store/${c.directory}`,label:c.directory,kind:"store",documents:c.files.map(x=>l(c.directory,x))})),...r&&r.loose.length>0?[{id:"store",label:"Store",kind:"store",documents:r.loose.map(c=>l(void 0,c))}]:[],...d&&d.artifacts.length>0?[ia(o,d)]:[]],n=De(a.messages,a.actorConversations),L=[...oe(n),...la(n,e,a.session.id)];return L.length>0&&f.push({id:"chat",label:"Shown in chat",kind:"chat",documents:L}),{sections:f,truncated:r?.truncated??!1}},na=e=>{function a({navigation:o,selection:d,session:l}){let{listing:f,error:n}=Oe(),{sections:L,truncated:c}=C(()=>He(e,l,f),[l.messages,l.actorConversations,l.runView,l.session.id,f]);return i(O,{children:[n&&t(Z,{className:"shrink-0 rounded-none border-x-0 border-t-0 border-b-border-soft bg-destructive/8 px-2.5 py-2 text-[0.68rem]",variant:"destructive",children:n}),t(be,{activeId:typeof d=="string"?d:void 0,sections:L,truncated:c,onSelect:x=>o.openTab(k,x??null)})]})}function r({session:o}){let{listing:d}=Oe(),{sections:l}=C(()=>He(e,o,d),[o.messages,o.actorConversations,o.runView,o.session.id,d]),f=l.reduce((n,L)=>n+L.documents.length,0);return f>0?t(R,{className:"tabular-nums",variant:"secondary",children:f}):null}return{DocumentsPanelContribution:a,DocumentsBadge:r}};function ca({navigation:e,session:a,tool:r,routePrefix:o}){let d=Ge(r,o,a.session.id);if(!d)return null;let l=r.isError?"error":r.result===void 0?"running":"ready";return t(Me,{active:e.activeTabId===k&&e.selectionFor(k)===d.id,document:d,onOpen:()=>e.openTab(k,d.id),status:l})}function pa(){return t("svg",{"aria-hidden":!0,fill:"none",height:"15",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.7",viewBox:"0 0 24 24",width:"15",children:t("path",{d:"M6 3h8l4 4v14H6zM14 3v5h4M9 13h6M9 17h4"})})}var ma=(e,a)=>{let{DocumentsPanelContribution:r,DocumentsBadge:o}=na(a);return{...e,needsRunView:!0,SessionProvider:sa,workspaceTabs:[{id:k,label:"Documents",order:200,Icon:pa,Panel:r,Badge:o}],toolPresenters:[{toolName:"show_document",Inline:d=>t(ca,{...d,routePrefix:a}),reveal:(d,l)=>Ge(d,a,l.session.id)?{tabId:k,selection:d.id}:void 0}],entityPresenters:[{reveal:d=>d.type==="artifact"?{tabId:k,selection:d.id}:void 0}]}},ie={id:ra},gu={...ie,activate:e=>ma(ie,se(ie.id,e))};export{ra as DOCUMENTS_PLUGIN_ID,k as DOCUMENTS_TAB_ID,gu as webPlugin};
2
2
  /*! Bundled license information:
3
3
 
4
4
  lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs: