@agentskit/doc-bridge 0.1.0-alpha.1 → 0.1.0-alpha.2

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 (61) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/dist/cli/program.js +283 -105
  4. package/dist/cli/program.js.map +1 -1
  5. package/dist/config/index.d.ts +1 -1
  6. package/dist/config/index.js +6 -3
  7. package/dist/config/index.js.map +1 -1
  8. package/dist/{index-CD_zmKXf.d.ts → index-CPUJbTbg.d.ts} +19 -10
  9. package/dist/index.d.ts +5 -4
  10. package/dist/index.js +278 -100
  11. package/dist/index.js.map +1 -1
  12. package/docs/DOGFOOD.md +92 -0
  13. package/package.json +27 -9
  14. package/scripts/prepare.mjs +44 -0
  15. package/src/cli/program.ts +933 -0
  16. package/src/config/defaults.ts +63 -0
  17. package/src/config/define-config.ts +6 -0
  18. package/src/config/index.ts +15 -0
  19. package/src/config/load-config.ts +138 -0
  20. package/src/config/schema.ts +294 -0
  21. package/src/federation/llms.ts +145 -0
  22. package/src/gates/run-gates.ts +274 -0
  23. package/src/index-builder/build-handoffs.ts +217 -0
  24. package/src/index-builder/build-index.ts +137 -0
  25. package/src/index-builder/capabilities.ts +37 -0
  26. package/src/index-builder/content-hash.ts +19 -0
  27. package/src/index-builder/human-adapters/core.ts +100 -0
  28. package/src/index-builder/human-adapters/docusaurus.ts +113 -0
  29. package/src/index-builder/human-adapters/fumadocs.ts +70 -0
  30. package/src/index-builder/human-adapters/index.ts +52 -0
  31. package/src/index-builder/human-adapters/plain-markdown.ts +10 -0
  32. package/src/index-builder/llms-txt.ts +19 -0
  33. package/src/index-builder/plugins/human-markdown.ts +7 -0
  34. package/src/index-builder/plugins/pnpm-monorepo.ts +72 -0
  35. package/src/index-builder/scan-corpus.ts +181 -0
  36. package/src/index.ts +120 -0
  37. package/src/intelligence/adapter.ts +90 -0
  38. package/src/intelligence/chat.ts +148 -0
  39. package/src/intelligence/peers.ts +59 -0
  40. package/src/intelligence/rag.ts +98 -0
  41. package/src/lib/glob-expand.ts +33 -0
  42. package/src/lib/markdown.ts +90 -0
  43. package/src/lib/package-manager.ts +104 -0
  44. package/src/lib/paths.ts +6 -0
  45. package/src/lib/walk.ts +45 -0
  46. package/src/mcp/server.ts +276 -0
  47. package/src/memory/ingest.ts +51 -0
  48. package/src/memory/pipeline.ts +119 -0
  49. package/src/query/load-index.ts +25 -0
  50. package/src/query/query.ts +142 -0
  51. package/src/query/search.ts +58 -0
  52. package/src/retriever/doc-bridge-retriever.ts +62 -0
  53. package/src/schemas/agent-handoff.ts +82 -0
  54. package/src/schemas/doc-bridge-index.ts +106 -0
  55. package/src/schemas/json-schemas.ts +156 -0
  56. package/src/schemas/memory-candidate.ts +37 -0
  57. package/src/shims/agentskit-peers.d.ts +80 -0
  58. package/src/validate.ts +67 -0
  59. package/src/version.ts +1 -0
  60. package/tsconfig.json +21 -0
  61. package/tsup.config.ts +15 -0
@@ -0,0 +1,80 @@
1
+ /** Ambient types for optional Layer-1 peers (not installed with Layer 0). */
2
+
3
+ declare module '@agentskit/rag' {
4
+ export type InputDocument = {
5
+ id?: string
6
+ content: string
7
+ source?: string
8
+ metadata?: Record<string, unknown>
9
+ }
10
+ export type RAG = {
11
+ ingest: (documents: InputDocument[]) => Promise<void>
12
+ search: (
13
+ query: string,
14
+ options?: { topK?: number; threshold?: number },
15
+ ) => Promise<
16
+ ReadonlyArray<{
17
+ id?: string
18
+ content: string
19
+ score?: number
20
+ metadata?: Record<string, unknown>
21
+ source?: string
22
+ }>
23
+ >
24
+ retrieve: (request: { query: string }) => Promise<unknown[]>
25
+ }
26
+ export function createRAG(config: {
27
+ embed: unknown
28
+ store: unknown
29
+ chunkSize?: number
30
+ chunkOverlap?: number
31
+ topK?: number
32
+ }): RAG
33
+ }
34
+
35
+ declare module '@agentskit/memory' {
36
+ export function fileVectorMemory(options: { path: string }): unknown
37
+ }
38
+
39
+ declare module '@agentskit/adapters' {
40
+ export function ollama(options: { model?: string; baseUrl?: string }): unknown
41
+ export function openai(options: { apiKey: string; model?: string; baseUrl?: string }): unknown
42
+ export function anthropic(options: { apiKey: string; model?: string }): unknown
43
+ export function openrouter(options: { apiKey: string; model?: string }): unknown
44
+ export function ollamaEmbedder(options?: { model?: string; baseUrl?: string }): unknown
45
+ export function openaiEmbedder(options: { apiKey: string; model?: string }): unknown
46
+ }
47
+
48
+ declare module '@agentskit/core' {
49
+ export function createChatController(config: Record<string, unknown>): {
50
+ send: (input: string) => Promise<{ content?: string; messages?: unknown[] }>
51
+ messages?: unknown[]
52
+ }
53
+ export function formatRetrievedDocuments(docs: unknown[]): string
54
+ export function createStaticRetriever(docs: unknown[]): unknown
55
+ }
56
+
57
+ declare module '@agentskit/ink' {
58
+ export function useChat(config: Record<string, unknown>): {
59
+ messages: ReadonlyArray<{ id: string; role: string; content: string }>
60
+ send: (input: string) => Promise<void>
61
+ isStreaming?: boolean
62
+ }
63
+ export const ChatContainer: unknown
64
+ export const Message: unknown
65
+ export const InputBar: unknown
66
+ }
67
+
68
+ declare module 'ink' {
69
+ export function render(node: unknown): { unmount: () => void; waitUntilExit: () => Promise<void> }
70
+ }
71
+
72
+ declare module 'react' {
73
+ export function createElement(
74
+ type: unknown,
75
+ props?: Record<string, unknown> | null,
76
+ ...children: unknown[]
77
+ ): unknown
78
+ const React: { createElement: typeof createElement }
79
+ export default React
80
+ }
@@ -0,0 +1,67 @@
1
+ import { ZodError } from 'zod'
2
+
3
+ import { DocBridgeConfigV1Schema, type DocBridgeConfigV1 } from './config/schema.js'
4
+ import {
5
+ AgentHandoffLegacySchema,
6
+ AgentHandoffV1Schema,
7
+ AgentSearchV1Schema,
8
+ normalizeAgentHandoff,
9
+ type AgentHandoffV1,
10
+ type AgentSearchV1,
11
+ } from './schemas/agent-handoff.js'
12
+ import { DocBridgeIndexV1Schema, type DocBridgeIndexV1 } from './schemas/doc-bridge-index.js'
13
+ import {
14
+ MemoryCandidateV1Schema,
15
+ type MemoryCandidateV1,
16
+ } from './schemas/memory-candidate.js'
17
+
18
+ export type ParseIssue = {
19
+ readonly path: string
20
+ readonly message: string
21
+ }
22
+
23
+ export type ParseResult<T> =
24
+ | { readonly ok: true; readonly value: T }
25
+ | { readonly ok: false; readonly issues: readonly ParseIssue[] }
26
+
27
+ const zodIssues = (error: ZodError): readonly ParseIssue[] =>
28
+ error.issues.map((issue) => ({
29
+ path: issue.path.join('.') || '(root)',
30
+ message: issue.message,
31
+ }))
32
+
33
+ export const safeParseAgentHandoff = (input: unknown): ParseResult<AgentHandoffV1> => {
34
+ const legacy = AgentHandoffLegacySchema.safeParse(input)
35
+ if (!legacy.success) return { ok: false, issues: zodIssues(legacy.error) }
36
+ const normalized = AgentHandoffV1Schema.safeParse(normalizeAgentHandoff(legacy.data))
37
+ if (!normalized.success) return { ok: false, issues: zodIssues(normalized.error) }
38
+ return { ok: true, value: normalized.data }
39
+ }
40
+
41
+ export const parseAgentHandoff = (input: unknown): AgentHandoffV1 => {
42
+ const result = safeParseAgentHandoff(input)
43
+ if (!result.ok) {
44
+ throw new Error(
45
+ `Invalid AgentHandoff:\n${result.issues.map((i) => ` - ${i.path}: ${i.message}`).join('\n')}`,
46
+ )
47
+ }
48
+ return result.value
49
+ }
50
+
51
+ export const parseAgentSearch = (input: unknown): AgentSearchV1 => AgentSearchV1Schema.parse(input)
52
+
53
+ export const parseDocBridgeIndex = (input: unknown): DocBridgeIndexV1 =>
54
+ DocBridgeIndexV1Schema.parse(input)
55
+
56
+ export const parseMemoryCandidate = (input: unknown): MemoryCandidateV1 =>
57
+ MemoryCandidateV1Schema.parse(input)
58
+
59
+ export const parseDocBridgeConfig = (input: unknown): DocBridgeConfigV1 => {
60
+ const result = DocBridgeConfigV1Schema.safeParse(input)
61
+ if (!result.success) {
62
+ throw new Error(
63
+ `Invalid doc-bridge config:\n${zodIssues(result.error).map((i) => ` - ${i.path}: ${i.message}`).join('\n')}`,
64
+ )
65
+ }
66
+ return result.data
67
+ }
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const PACKAGE_VERSION = '0.1.0-alpha.2'
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "types": ["node"],
8
+ "strict": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "exactOptionalPropertyTypes": true,
11
+ "skipLibCheck": true,
12
+ "ignoreDeprecations": "6.0",
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+ "sourceMap": true,
16
+ "outDir": "dist",
17
+ "rootDir": "src"
18
+ },
19
+ "include": ["src/**/*.ts"],
20
+ "exclude": ["node_modules", "dist"]
21
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: 'src/index.ts',
6
+ 'config/index': 'src/config/index.ts',
7
+ 'cli/program': 'src/cli/program.ts',
8
+ },
9
+ format: ['esm'],
10
+ dts: true,
11
+ sourcemap: true,
12
+ clean: true,
13
+ splitting: false,
14
+ target: 'node22',
15
+ })