@arbidocs/blocks 0.4.127 → 0.4.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/index.cjs +303 -303
- package/dist/agents/index.js +11 -11
- package/dist/calls/index.cjs +1 -1
- package/dist/calls/index.js +1 -1
- package/dist/chat/index.cjs +152 -135
- package/dist/chat/index.d.ts +1 -0
- package/dist/chat/index.js +5 -4
- package/dist/chat/open-document.d.ts +66 -0
- package/dist/{chunk-DZI7WOUD.cjs → chunk-3BJLNKOB.cjs} +6 -2
- package/dist/chunk-3BJLNKOB.cjs.map +1 -0
- package/dist/{chunk-2PNNCEPH.js → chunk-54ANPPMV.js} +4 -4
- package/dist/{chunk-2PNNCEPH.js.map → chunk-54ANPPMV.js.map} +1 -1
- package/dist/{chunk-T6I6ZCBE.js → chunk-7BJRLP3U.js} +7 -4
- package/dist/chunk-7BJRLP3U.js.map +1 -0
- package/dist/{chunk-2DFDFOM7.js → chunk-7HAM7Y5U.js} +3 -3
- package/dist/{chunk-2DFDFOM7.js.map → chunk-7HAM7Y5U.js.map} +1 -1
- package/dist/{chunk-6Z72CXZR.js → chunk-CJBN5HIS.js} +6 -2
- package/dist/chunk-CJBN5HIS.js.map +1 -0
- package/dist/{chunk-PUCY3UXN.js → chunk-CXLVI3SB.js} +3 -3
- package/dist/{chunk-PUCY3UXN.js.map → chunk-CXLVI3SB.js.map} +1 -1
- package/dist/{chunk-KYDRUFWT.cjs → chunk-D4YR56FV.cjs} +5 -5
- package/dist/{chunk-KYDRUFWT.cjs.map → chunk-D4YR56FV.cjs.map} +1 -1
- package/dist/{chunk-ZLRQ5K77.cjs → chunk-FSBY2S4V.cjs} +8 -5
- package/dist/chunk-FSBY2S4V.cjs.map +1 -0
- package/dist/chunk-GYCQ3FNL.js +60 -0
- package/dist/chunk-GYCQ3FNL.js.map +1 -0
- package/dist/{chunk-6AALMYPS.cjs → chunk-HM23LXUP.cjs} +3 -3
- package/dist/{chunk-6AALMYPS.cjs.map → chunk-HM23LXUP.cjs.map} +1 -1
- package/dist/{chunk-T2CVFK2I.js → chunk-KLOSOT26.js} +11 -11
- package/dist/{chunk-T2CVFK2I.js.map → chunk-KLOSOT26.js.map} +1 -1
- package/dist/{chunk-SARREDFP.cjs → chunk-LC2KJSUS.cjs} +46 -46
- package/dist/{chunk-SARREDFP.cjs.map → chunk-LC2KJSUS.cjs.map} +1 -1
- package/dist/{chunk-XFKF3WRN.cjs → chunk-NZUQFF35.cjs} +5 -5
- package/dist/{chunk-XFKF3WRN.cjs.map → chunk-NZUQFF35.cjs.map} +1 -1
- package/dist/{chunk-5Y7JRY7Y.js → chunk-P5ST47VY.js} +3 -3
- package/dist/{chunk-5Y7JRY7Y.js.map → chunk-P5ST47VY.js.map} +1 -1
- package/dist/chunk-SWQX6CTT.cjs +65 -0
- package/dist/chunk-SWQX6CTT.cjs.map +1 -0
- package/dist/{chunk-ENDP7JER.js → chunk-VW2C2AZL.js} +3 -3
- package/dist/{chunk-ENDP7JER.js.map → chunk-VW2C2AZL.js.map} +1 -1
- package/dist/{chunk-MCPRNDOJ.cjs → chunk-W27VK32R.cjs} +79 -79
- package/dist/{chunk-MCPRNDOJ.cjs.map → chunk-W27VK32R.cjs.map} +1 -1
- package/dist/{chunk-PJJY6CYL.cjs → chunk-WV4IDVDQ.cjs} +11 -11
- package/dist/{chunk-PJJY6CYL.cjs.map → chunk-WV4IDVDQ.cjs.map} +1 -1
- package/dist/{chunk-UUXKB3WQ.js → chunk-ZCHSJUCI.js} +3 -3
- package/dist/{chunk-UUXKB3WQ.js.map → chunk-ZCHSJUCI.js.map} +1 -1
- package/dist/{chunk-NYHGG2IA.cjs → chunk-ZV3BKLFY.cjs} +3 -3
- package/dist/{chunk-NYHGG2IA.cjs.map → chunk-ZV3BKLFY.cjs.map} +1 -1
- package/dist/collaboration/index.cjs +9 -9
- package/dist/collaboration/index.js +1 -1
- package/dist/connect/docx.cjs +4 -3
- package/dist/connect/docx.cjs.map +1 -1
- package/dist/connect/docx.js +3 -2
- package/dist/connect/docx.js.map +1 -1
- package/dist/connect/index.cjs +53 -51
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +19 -17
- package/dist/connect/index.js.map +1 -1
- package/dist/connection/mail/types.d.ts +2 -6
- package/dist/document-tools/index.cjs +1 -1
- package/dist/document-tools/index.js +1 -1
- package/dist/facts/index.cjs +1 -1
- package/dist/facts/index.js +1 -1
- package/dist/files/index.cjs +1 -1
- package/dist/files/index.js +1 -1
- package/dist/home/index.cjs +17 -17
- package/dist/home/index.js +3 -3
- package/dist/index.cjs +645 -628
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -20
- package/dist/index.js.map +1 -1
- package/dist/settings/index.cjs +11 -11
- package/dist/settings/index.js +3 -3
- package/dist/shell/index.cjs +1 -1
- package/dist/shell/index.js +1 -1
- package/dist/site/index.cjs +5 -5
- package/dist/site/index.js +1 -1
- package/dist/studio/index.cjs +7 -6
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/index.js +6 -5
- package/dist/studio/index.js.map +1 -1
- package/dist/workflow-canvas/index.cjs +62 -62
- package/dist/workflow-canvas/index.js +11 -11
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/src/docx/README.md +7 -3
- package/dist/chunk-6Z72CXZR.js.map +0 -1
- package/dist/chunk-DZI7WOUD.cjs.map +0 -1
- package/dist/chunk-T6I6ZCBE.js.map +0 -1
- package/dist/chunk-ZLRQ5K77.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/connection/ai.tsx"],"names":["useConnection","useKitAiTask","useCallback","useKitWorkspaceDocs","useKitSemanticSearch","useWorkspaceUsers","useArbiChat","takeOpenDocumentForTurn","jsx","AssistantDock"],"mappings":";;;;;;;;;AAiCO,SAAS,kBAAA,GAAqB;AACnC,EAAA,MAAM,EAAE,eAAA,EAAgB,GAAIA,+BAAA,EAAc;AAC1C,E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AU,EAAA,KAAO,OAAA,CAAQ,QAAQ,CAAA,EAAG;AAAA,UAElF;AAAC,KACP,CAAE;AAAA,GACJ;AACF;AAMO,SAAS,uBAAuB,KAAA,EAAyC;AAC9E,EAAA,MAAM,OAAO,gBAAA,EAAiB;AAC9B,EAAA,uBAAOC,cAAA,CAACC,+BAAA,EAAA,EAAe,GAAG,KAAA,EAAO,IAAA,EAAY,CAAA;AAC/C","file":"chunk-FSBY2S4V.cjs","sourcesContent":["/**\n * The connected agent hooks — thin adapters over the reusable AI kit in\n * `@arbidocs/react`. The streaming/accumulation/search plumbing lives once in\n * the SDK; these hooks only bind the *workspace source* (from the connection\n * context, falling back to the configured workspace) and inject the host's\n * default assistant *configuration* so call sites needn't know the config\n * ext_id. An explicit `opts.model` still wins.\n */\nimport { useCallback } from 'react'\nimport {\n useAiTask as useKitAiTask,\n useWorkspaceDocs as useKitWorkspaceDocs,\n useSemanticSearch as useKitSemanticSearch,\n useArbiChat,\n useWorkspaceUsers,\n type ArbiChat,\n type UseArbiChatOptions,\n type AiRunOptions,\n} from '@arbidocs/react'\nimport { useConnection } from './ConnectionProvider'\nimport { AssistantDock, type AssistantDockProps } from '../chat/AssistantDock'\nimport type { MentionCandidate } from '../chat/mentions'\nimport { takeOpenDocumentForTurn } from '../chat/open-document'\n\nexport type { AiTaskStatus, AiRunOptions, SearchChunk, ArtifactEvent } from '@arbidocs/react'\n\n/** Client-side redlining, re-exported so a host app has one import surface. */\nexport { toRedlineMarkdown, redlineStats, textToArtifact } from '@arbidocs/react'\n\n/**\n * The kit's `useAiTask` with the host's default assistant configuration\n * injected, so call sites needn't know the config ext_id.\n */\nexport function useConnectedAiTask() {\n const { assistantConfig } = useConnection()\n const task = useKitAiTask()\n const kitRun = task.run\n const run = useCallback(\n (question: string, docIds: string[], opts?: AiRunOptions) =>\n kitRun(question, docIds, { ...opts, model: opts?.model ?? assistantConfig }),\n [kitRun, assistantConfig]\n )\n return { ...task, run }\n}\n\n/** Resolve the active workspace + its document ids (what we ground the agent on). */\nexport function useWorkspaceDocs() {\n const { workspaceId, fallbackWorkspaceId } = useConnection()\n return useKitWorkspaceDocs(workspaceId ?? fallbackWorkspaceId)\n}\n\n/** Search the active workspace's documents and return the top matching passages. */\nexport function useSemanticSearch() {\n const { docIds } = useWorkspaceDocs()\n return useKitSemanticSearch(docIds)\n}\n\n/**\n * The chat controller for `ChatPage` bound to the connection: the active workspace and the host's\n * default assistant configuration are injected, so a host writes\n * `<ChatPage chat={useConnectedChat()} />`.\n */\nexport function useConnectedChat(\n options?: Omit<UseArbiChatOptions, 'workspaceId'>\n): ArbiChat & { mentionCandidates: MentionCandidate[] } {\n const { workspaceId, fallbackWorkspaceId, assistantConfig, user, status, ensureWorkspaceOpen } =\n useConnection()\n const wsId = workspaceId ?? fallbackWorkspaceId\n const { data: members = [] } = useWorkspaceUsers(wsId, {\n enabled: status === 'authenticated' && !!wsId,\n beforeFetch: ensureWorkspaceOpen,\n })\n const mentionCandidates: MentionCandidate[] = [\n { id: 'assistant', kind: 'assistant', label: 'Assistant' },\n ...(status === 'authenticated' ? members : [])\n .filter(\n (member) =>\n !member.agent_ext_id &&\n member.user.external_id !== user?.externalId &&\n !member.user.external_id.startsWith('agt-')\n )\n .map((member) => ({\n id: member.user.external_id,\n kind: 'user' as const,\n label:\n [member.user.given_name, member.user.family_name].filter(Boolean).join(' ') ||\n member.user.email,\n description: member.user.email,\n }))\n .sort((a, b) => a.label.localeCompare(b.label)),\n ]\n const chat = useArbiChat({\n // Drafting mode: each question names the document open beside the chat.\n activeArtifact: () => takeOpenDocumentForTurn({ workspaceId: wsId }),\n ...options,\n workspaceId: wsId,\n model: options?.model ?? assistantConfig,\n })\n return {\n ...chat,\n mentionCandidates,\n messages: chat.messages.map((message) => ({\n ...message,\n ...(message.authorId\n ? {\n senderName:\n message.authorId === user?.externalId\n ? user?.name || user?.email\n : mentionCandidates.find((candidate) => candidate.id === message.authorId)?.label,\n }\n : {}),\n })),\n }\n}\n\n/**\n * The assistant dock bound to the connection: mount it once in the layout (`Shell.Root`'s `aside`)\n * and put `AssistantDockToggle` in the topbar. Chat state lives here, so it survives closing the dock.\n */\nexport function ConnectedAssistantDock(props: Omit<AssistantDockProps, 'chat'>) {\n const chat = useConnectedChat()\n return <AssistantDock {...props} chat={chat} />\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef, useEffect, useSyncExternalStore } from 'react';
|
|
3
|
+
import { parseVersionRef } from '@arbidocs/react/artifacts';
|
|
4
|
+
|
|
5
|
+
// src/chat/open-document.ts
|
|
6
|
+
function savedDocumentIdFor(input) {
|
|
7
|
+
const { documentId, isDraft, isStreaming, isBlobArtifact, documentData } = input;
|
|
8
|
+
if (!documentId || isDraft || isStreaming || isBlobArtifact) return null;
|
|
9
|
+
if (documentData?.wp_type !== "artifact" && !documentData?.file_name?.toLowerCase().endsWith(".docx"))
|
|
10
|
+
return null;
|
|
11
|
+
if (documentData.external_id !== documentId) return null;
|
|
12
|
+
return documentId;
|
|
13
|
+
}
|
|
14
|
+
var entries = [];
|
|
15
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
16
|
+
function subscribe(listener) {
|
|
17
|
+
listeners.add(listener);
|
|
18
|
+
return () => listeners.delete(listener);
|
|
19
|
+
}
|
|
20
|
+
function emit() {
|
|
21
|
+
listeners.forEach((l) => l());
|
|
22
|
+
}
|
|
23
|
+
var top = () => entries[entries.length - 1];
|
|
24
|
+
function useRegisterOpenDocument(registration) {
|
|
25
|
+
const latest = useRef(registration);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
latest.current = registration;
|
|
28
|
+
});
|
|
29
|
+
const { documentId } = registration;
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!documentId) return;
|
|
32
|
+
const entry = { documentId, current: () => latest.current };
|
|
33
|
+
entries = [...entries, entry];
|
|
34
|
+
emit();
|
|
35
|
+
return () => {
|
|
36
|
+
entries = entries.filter((e) => e !== entry);
|
|
37
|
+
emit();
|
|
38
|
+
};
|
|
39
|
+
}, [documentId]);
|
|
40
|
+
}
|
|
41
|
+
function useOpenDocumentId() {
|
|
42
|
+
return useSyncExternalStore(
|
|
43
|
+
subscribe,
|
|
44
|
+
() => top()?.documentId ?? null,
|
|
45
|
+
() => null
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function takeOpenDocumentForTurn(options) {
|
|
49
|
+
const entry = top();
|
|
50
|
+
if (!entry) return null;
|
|
51
|
+
const { shownId, showLive, workspaceId } = entry.current();
|
|
52
|
+
if (options?.workspaceId && workspaceId && options.workspaceId !== workspaceId) return null;
|
|
53
|
+
if (shownId && shownId !== entry.documentId && parseVersionRef(shownId).docId === entry.documentId)
|
|
54
|
+
showLive?.();
|
|
55
|
+
return entry.documentId;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { savedDocumentIdFor, takeOpenDocumentForTurn, useOpenDocumentId, useRegisterOpenDocument };
|
|
59
|
+
//# sourceMappingURL=chunk-GYCQ3FNL.js.map
|
|
60
|
+
//# sourceMappingURL=chunk-GYCQ3FNL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chat/open-document.ts"],"names":[],"mappings":";;;;AA2CO,SAAS,mBAAmB,KAAA,EAA0C;AAC3E,EAAA,MAAM,EAAE,UAAA,EAAY,OAAA,EAAS,WAAA,EAAa,cAAA,EAAgB,cAAa,GAAI,KAAA;AAC3E,EAAA,IAAI,CAAC,UAAA,IAAc,OAAA,IAAW,WAAA,IAAe,gBAAgB,OAAO,IAAA;AACpE,EAAA,IACE,YAAA,EAAc,YAAY,UAAA,IAC1B,CAAC,cAAc,SAAA,EAAW,WAAA,EAAY,CAAE,QAAA,CAAS,OAAO,CAAA;AAExD,IAAA,OAAO,IAAA;AAET,EAAA,IAAI,YAAA,CAAa,WAAA,KAAgB,UAAA,EAAY,OAAO,IAAA;AACpD,EAAA,OAAO,UAAA;AACT;AAkBA,IAAI,UAAmB,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,GAAA,EAAI;AAClB,EAAA,IAAI,CAAC,OAAO,OAAO,IAAA;AACnB,EAAA,MAAM,EAAE,OAAA,EAAS,QAAA,EAAU,WAAA,EAAY,GAAI,MAAM,OAAA,EAAQ;AACzD,EAAA,IAAI,SAAS,WAAA,IAAe,WAAA,IAAe,OAAA,CAAQ,WAAA,KAAgB,aAAa,OAAO,IAAA;AACvF,EAAA,IACE,OAAA,IACA,YAAY,KAAA,CAAM,UAAA,IAClB,gBAAgB,OAAO,CAAA,CAAE,UAAU,KAAA,CAAM,UAAA;AAEzC,IAAA,QAAA,IAAW;AACb,EAAA,OAAO,KAAA,CAAM,UAAA;AACf","file":"chunk-GYCQ3FNL.js","sourcesContent":["import { useEffect, useRef, useSyncExternalStore } from 'react'\nimport { parseVersionRef } from '@arbidocs/react/artifacts'\n\n/**\n * Drafting mode: the saved document open beside the chat is what a chat turn is about.\n *\n * A viewer registers the document it shows (`useRegisterOpenDocument`); every assistant turn names\n * it (`active_artifact_ext_id`, read with `takeOpenDocumentForTurn` as the question is sent), so the\n * server binds the live document to the turn: a Word document is read on demand and edited as\n * tracked changes in the open editor, and what the assistant saves becomes a child version of it.\n * The request carries a reference, never the content.\n *\n * The open document is always the subject, also while one of its earlier versions is on screen\n * read-only: a version still names its document. Sending a turn then returns the viewer to the live\n * document (`showLive`), where the assistant's edits appear as they are made. (Pinning a specific\n * version as a source is a separate feature: it does not go through here.)\n *\n * A module-level registry (not React context), like `useChatSurface`, so a viewer and a chat agree\n * wherever they sit in the tree; the most recently opened document wins and closing it hands back\n * to the one before.\n */\n\n/** What a viewer knows about the document it shows. */\nexport interface SavedDocumentInput {\n /** The document (`doc-…`), never a version reference. */\n documentId: string | null | undefined\n /** An unsaved draft (client-minted id, no backend record). */\n isDraft: boolean\n /** Still streaming: nothing is persisted yet. */\n isStreaming: boolean\n /** An image, audio or video artifact: there is no text to draft in. */\n isBlobArtifact: boolean\n /** The loaded document record. */\n documentData:\n | { external_id?: string | null; wp_type?: string | null; file_name?: string | null }\n | null\n | undefined\n}\n\n/**\n * The saved, content-backed document a chat can draft in, or null. Only a saved artifact or Word\n * document counts: drafts, an artifact still streaming and blob artifacts do not.\n */\nexport function savedDocumentIdFor(input: SavedDocumentInput): string | null {\n const { documentId, isDraft, isStreaming, isBlobArtifact, documentData } = input\n if (!documentId || isDraft || isStreaming || isBlobArtifact) return null\n if (\n documentData?.wp_type !== 'artifact' &&\n !documentData?.file_name?.toLowerCase().endsWith('.docx')\n )\n return null\n // A stale record of the previously viewed document is not this one.\n if (documentData.external_id !== documentId) return null\n return documentId\n}\n\nexport interface OpenDocumentRegistration {\n /** The saved document the viewer shows (`doc-…`); null or empty registers nothing. */\n documentId: string | null | undefined\n /** What is on screen: the document itself, or one of its earlier versions (`doc-…@v2`). */\n shownId?: string | null\n /** Show the live document again. Called when a turn starts while an earlier version is shown. */\n showLive?: () => void\n /** The workspace the document belongs to; a chat in another workspace does not draft in it. */\n workspaceId?: string | null\n}\n\ninterface Entry {\n documentId: string\n current: () => OpenDocumentRegistration\n}\n\nlet entries: Entry[] = []\nconst listeners = new Set<() => void>()\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\nfunction emit() {\n listeners.forEach((l) => l())\n}\n\nconst top = (): Entry | undefined => entries[entries.length - 1]\n\n/**\n * Registers the document a viewer shows as the open document while the caller is mounted and\n * `documentId` is set. Pass `savedDocumentIdFor(...)`, or the id of a document known to be saved.\n */\nexport function useRegisterOpenDocument(registration: OpenDocumentRegistration): void {\n const latest = useRef(registration)\n useEffect(() => {\n latest.current = registration\n })\n const { documentId } = registration\n useEffect(() => {\n if (!documentId) return\n const entry: Entry = { documentId, current: () => latest.current }\n entries = [...entries, entry]\n emit()\n return () => {\n entries = entries.filter((e) => e !== entry)\n emit()\n }\n }, [documentId])\n}\n\n/** The open document's id, or null. Re-renders when another document opens or it closes. */\nexport function useOpenDocumentId(): string | null {\n return useSyncExternalStore(\n subscribe,\n () => top()?.documentId ?? null,\n () => null\n )\n}\n\n/**\n * The document an assistant turn about to be sent drafts in, or null. Call it once per turn as the\n * question is sent: when an earlier version of the document is on screen, the viewer returns to the\n * live document, where the assistant's edits appear. With `workspaceId`, a document registered in\n * another workspace is not named (and its viewer is left alone).\n */\nexport function takeOpenDocumentForTurn(options?: { workspaceId?: string | null }): string | null {\n const entry = top()\n if (!entry) return null\n const { shownId, showLive, workspaceId } = entry.current()\n if (options?.workspaceId && workspaceId && options.workspaceId !== workspaceId) return null\n if (\n shownId &&\n shownId !== entry.documentId &&\n parseVersionRef(shownId).docId === entry.documentId\n )\n showLive?.()\n return entry.documentId\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var chunk32HW2Q33_cjs = require('./chunk-32HW2Q33.cjs');
|
|
5
4
|
var chunk7UTB4PHM_cjs = require('./chunk-7UTB4PHM.cjs');
|
|
5
|
+
var chunk32HW2Q33_cjs = require('./chunk-32HW2Q33.cjs');
|
|
6
6
|
var chunkPPCATBOY_cjs = require('./chunk-PPCATBOY.cjs');
|
|
7
7
|
var lucideReact = require('lucide-react');
|
|
8
8
|
var ui = require('@arbidocs/react/ui');
|
|
@@ -972,5 +972,5 @@ exports.workflowFromFrontmatter = workflowFromFrontmatter;
|
|
|
972
972
|
exports.workflowSteps = workflowSteps;
|
|
973
973
|
exports.workflowsAccepting = workflowsAccepting;
|
|
974
974
|
exports.workflowsForHost = workflowsForHost;
|
|
975
|
-
//# sourceMappingURL=chunk-
|
|
976
|
-
//# sourceMappingURL=chunk-
|
|
975
|
+
//# sourceMappingURL=chunk-HM23LXUP.cjs.map
|
|
976
|
+
//# sourceMappingURL=chunk-HM23LXUP.cjs.map
|