@krak-stack/registry 0.1.2 → 0.1.3
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/README.md +17 -1
- package/dist/components/ui/alert.d.ts +10 -0
- package/dist/components/ui/bubble.d.ts +16 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/empty.d.ts +11 -0
- package/dist/components/ui/marker.d.ts +10 -0
- package/dist/components/ui/message-scroller.d.ts +10 -0
- package/dist/components/ui/message.d.ts +10 -0
- package/dist/lib/docs-ai.d.ts +136 -0
- package/dist/lib/docs-ai.js +310 -0
- package/dist/lib/docs-core.d.ts +681 -0
- package/dist/lib/docs-core.js +2571 -0
- package/dist/lib/httpapi-ai.d.ts +54 -0
- package/dist/lib/httpapi-ai.js +361 -0
- package/dist/lib/httpapi-cli.d.ts +22 -0
- package/dist/lib/httpapi-cli.js +412 -0
- package/dist/lib/httpapi-client.d.ts +20 -0
- package/dist/lib/httpapi-client.js +50 -0
- package/dist/lib/httpapi-helpers.d.ts +105 -0
- package/dist/lib/httpapi-helpers.js +237 -0
- package/dist/lib/httpapi-mcp.d.ts +20 -0
- package/dist/lib/httpapi-mcp.js +366 -0
- package/dist/lib/query.js +128 -0
- package/dist/services/agent/client/atom.d.ts +56 -0
- package/dist/services/agent/client/index.d.ts +2 -0
- package/dist/services/agent/client/index.js +2239 -0
- package/dist/services/agent/client/widget.d.ts +52 -0
- package/dist/services/agent/index.d.ts +111 -0
- package/dist/services/agent/index.js +190 -0
- package/dist/services/agent/schema.d.ts +161 -0
- package/dist/services/agent/schema.js +135 -0
- package/package.json +58 -2
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// ../../src/lib/query.ts
|
|
2
|
+
import {
|
|
3
|
+
Effect,
|
|
4
|
+
Option,
|
|
5
|
+
Schema,
|
|
6
|
+
SchemaIssue,
|
|
7
|
+
SchemaTransformation
|
|
8
|
+
} from "effect";
|
|
9
|
+
var parseSortParam = (sort) => {
|
|
10
|
+
const id = sort.startsWith("-") ? sort.slice(1) : sort;
|
|
11
|
+
if (!id || id.includes(",") || id.includes(":")) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
15
|
+
};
|
|
16
|
+
var SortDirection = Schema.Union([
|
|
17
|
+
Schema.Literal("asc"),
|
|
18
|
+
Schema.Literal("desc")
|
|
19
|
+
]).pipe(Schema.annotate({
|
|
20
|
+
identifier: "SortDirection",
|
|
21
|
+
title: "Sort Direction",
|
|
22
|
+
description: "Sort direction for list query results.",
|
|
23
|
+
examples: ["asc", "desc"]
|
|
24
|
+
}));
|
|
25
|
+
var SortParam = Schema.Struct({
|
|
26
|
+
id: Schema.NonEmptyString,
|
|
27
|
+
direction: SortDirection
|
|
28
|
+
}).pipe(Schema.annotate({
|
|
29
|
+
identifier: "SortParam",
|
|
30
|
+
title: "Sort Parameter",
|
|
31
|
+
description: "Decoded sort parameter with a field id and direction.",
|
|
32
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
33
|
+
}));
|
|
34
|
+
var SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam, SchemaTransformation.transformOrFail({
|
|
35
|
+
decode: (sort) => {
|
|
36
|
+
const sortParam = parseSortParam(sort);
|
|
37
|
+
if (!sortParam) {
|
|
38
|
+
return Effect.fail(new SchemaIssue.InvalidValue(Option.some(sort), {
|
|
39
|
+
message: 'Expected sort in the format "field" or "-field"'
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
return Effect.succeed(sortParam);
|
|
43
|
+
},
|
|
44
|
+
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
45
|
+
})), Schema.annotate({
|
|
46
|
+
identifier: "SortParamFromString",
|
|
47
|
+
title: "Sort Parameter From String",
|
|
48
|
+
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
49
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
50
|
+
}));
|
|
51
|
+
var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortParam), SchemaTransformation.transformOrFail({
|
|
52
|
+
decode: (sort) => {
|
|
53
|
+
const parts = sort.split(",");
|
|
54
|
+
const sortParams = [];
|
|
55
|
+
for (const part of parts) {
|
|
56
|
+
const sortParam = parseSortParam(part);
|
|
57
|
+
if (!sortParam) {
|
|
58
|
+
return Effect.fail(new SchemaIssue.InvalidValue(Option.some(sort), {
|
|
59
|
+
message: 'Expected sort in the format "field,-otherField"'
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
sortParams.push(sortParam);
|
|
63
|
+
}
|
|
64
|
+
return Effect.succeed(sortParams);
|
|
65
|
+
},
|
|
66
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema.encodeSync(SortParamFromString)(part)).join(","))
|
|
67
|
+
})), Schema.annotate({
|
|
68
|
+
identifier: "SortParamsFromString",
|
|
69
|
+
title: "Sort Parameters From String",
|
|
70
|
+
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
71
|
+
examples: [
|
|
72
|
+
[
|
|
73
|
+
{ id: "name", direction: "desc" },
|
|
74
|
+
{ id: "age", direction: "asc" }
|
|
75
|
+
]
|
|
76
|
+
]
|
|
77
|
+
}));
|
|
78
|
+
var SortParamSearch = SortParamsFromString.pipe(Schema.decodeTo(Schema.String, SchemaTransformation.transform({
|
|
79
|
+
decode: (sort) => Schema.encodeSync(SortParamsFromString)(sort),
|
|
80
|
+
encode: (sort) => Schema.decodeUnknownSync(SortParamsFromString)(sort)
|
|
81
|
+
})), Schema.annotate({
|
|
82
|
+
identifier: "SortParamSearch",
|
|
83
|
+
title: "Sort Search Parameter",
|
|
84
|
+
description: 'Search parameter sort value normalized to the compact "-field,otherField" URL format.',
|
|
85
|
+
examples: ["-name,age"]
|
|
86
|
+
}));
|
|
87
|
+
var Query = Schema.Struct({
|
|
88
|
+
page: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
89
|
+
pageSize: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })),
|
|
90
|
+
globalFilter: Schema.optional(Schema.String),
|
|
91
|
+
sort: Schema.optional(SortParamSearch)
|
|
92
|
+
}).annotate({
|
|
93
|
+
identifier: "Query",
|
|
94
|
+
title: "Query",
|
|
95
|
+
description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
|
|
96
|
+
examples: [
|
|
97
|
+
{
|
|
98
|
+
page: 0,
|
|
99
|
+
pageSize: 10,
|
|
100
|
+
globalFilter: "housing",
|
|
101
|
+
sort: "-publicName,createdAt"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
var PaginationMeta = Schema.Struct({
|
|
106
|
+
page: Schema.Int,
|
|
107
|
+
pageSize: Schema.Int,
|
|
108
|
+
total: Schema.Int,
|
|
109
|
+
pageCount: Schema.Int
|
|
110
|
+
}).pipe(Schema.annotate({
|
|
111
|
+
identifier: "PaginationMeta",
|
|
112
|
+
title: "Pagination Metadata",
|
|
113
|
+
description: "Pagination metadata returned with a paginated list response.",
|
|
114
|
+
examples: [{ page: 0, pageSize: 10, total: 125, pageCount: 13 }]
|
|
115
|
+
}));
|
|
116
|
+
var PaginatedResponse = (items) => Schema.Struct({
|
|
117
|
+
data: Schema.Array(items),
|
|
118
|
+
meta: PaginationMeta
|
|
119
|
+
});
|
|
120
|
+
export {
|
|
121
|
+
SortParamsFromString,
|
|
122
|
+
SortParamFromString,
|
|
123
|
+
SortParam,
|
|
124
|
+
SortDirection,
|
|
125
|
+
Query,
|
|
126
|
+
PaginationMeta,
|
|
127
|
+
PaginatedResponse
|
|
128
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Effect, Stream } from "effect";
|
|
2
|
+
import { Atom, Reactivity } from "effect/unstable/reactivity";
|
|
3
|
+
import type { AgentErrorCode, AgentEvent, AgentReference, AgentRequest } from "../schema.js";
|
|
4
|
+
export type AgentToolStatus = "running" | "approval-required" | "approved" | "denied" | "completed" | "failed";
|
|
5
|
+
export type AgentToolActivity = Extract<AgentEvent, {
|
|
6
|
+
readonly type: "tool-call";
|
|
7
|
+
}> & {
|
|
8
|
+
readonly approvalId?: string;
|
|
9
|
+
readonly status: AgentToolStatus;
|
|
10
|
+
};
|
|
11
|
+
export type AgentMessage = {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly role: "user" | "assistant";
|
|
14
|
+
readonly text: string;
|
|
15
|
+
readonly tools: ReadonlyArray<AgentToolActivity>;
|
|
16
|
+
};
|
|
17
|
+
export type AgentSubmitAction<Resource = never> = {
|
|
18
|
+
readonly type: "message";
|
|
19
|
+
readonly text: string;
|
|
20
|
+
readonly references?: ReadonlyArray<AgentReference<Resource>>;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "approval";
|
|
23
|
+
readonly approvalId: string;
|
|
24
|
+
readonly toolCallId: string;
|
|
25
|
+
readonly approved: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type AgentConversationContext<Resource> = AgentReference<Resource> & {
|
|
28
|
+
readonly key: string;
|
|
29
|
+
};
|
|
30
|
+
export type AgentState<Resource = never> = {
|
|
31
|
+
readonly context: AgentConversationContext<Resource> | undefined;
|
|
32
|
+
readonly contextLocked: boolean;
|
|
33
|
+
readonly messages: ReadonlyArray<AgentMessage>;
|
|
34
|
+
readonly history?: string;
|
|
35
|
+
readonly pending: boolean;
|
|
36
|
+
readonly error?: AgentErrorCode;
|
|
37
|
+
};
|
|
38
|
+
export declare const initialAgentState: AgentState<never>;
|
|
39
|
+
export declare const reduceAgentEvent: <Resource>(state: AgentState<Resource>, event: AgentEvent) => AgentState<Resource>;
|
|
40
|
+
export type AgentAtomsConfig<Resource> = {
|
|
41
|
+
readonly stream: (get: Atom.FnContext, request: AgentRequest<Resource>) => Effect.Effect<Stream.Stream<AgentEvent, unknown, Reactivity.Reactivity>, unknown>;
|
|
42
|
+
readonly errorCode?: (error: unknown) => AgentErrorCode;
|
|
43
|
+
readonly reactivityKeys?: ReadonlyArray<unknown>;
|
|
44
|
+
readonly runtime?: Atom.AtomRuntime<never>;
|
|
45
|
+
};
|
|
46
|
+
export type AgentSubmitInput<Resource> = {
|
|
47
|
+
readonly action: AgentSubmitAction<Resource>;
|
|
48
|
+
readonly context?: AgentConversationContext<Resource>;
|
|
49
|
+
readonly scope: string;
|
|
50
|
+
};
|
|
51
|
+
export declare const makeAgentAtoms: <Resource>({ errorCode, reactivityKeys, runtime, stream, }: AgentAtomsConfig<Resource>) => {
|
|
52
|
+
readonly removeContext: Atom.Writable<import("effect/Option").Option<void>, string>;
|
|
53
|
+
readonly reset: Atom.Writable<import("effect/Option").Option<void>, string>;
|
|
54
|
+
readonly state: (arg: string) => Atom.Writable<AgentState<Resource>, AgentState<Resource>>;
|
|
55
|
+
readonly submit: Atom.AtomResultFn<AgentSubmitInput<Resource>, void, never>;
|
|
56
|
+
};
|