@cognidesk/http 0.0.3-dev.7 → 0.0.3-dev.9
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 +33 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.js +32 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](LICENSES/Apache-2.0.txt)
|
|
8
8
|
[](LICENSES/Cognidesk-Studio-Source-Available-License.txt)
|
|
9
9
|
[](https://www.typescriptlang.org/)
|
|
10
|
-
[](https://nodejs.org/)
|
|
11
11
|
|
|
12
12
|
[Documentation](https://cognidesk.cognilabz.com) · [Quick Start](https://cognidesk.cognilabz.com/getting-started/quick-start/) · [Examples](https://cognidesk.cognilabz.com/examples/) · [API Reference](https://cognidesk.cognilabz.com/api-reference/)
|
|
13
13
|
|
|
@@ -41,7 +41,7 @@ const agent = createAgent("support", {
|
|
|
41
41
|
const runtime = createRuntime({
|
|
42
42
|
storage: createSqliteStorage({ filename: "data.sqlite" }),
|
|
43
43
|
agent,
|
|
44
|
-
models,
|
|
44
|
+
models, // See the Quick Start for createModelSet configuration.
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -66,32 +66,58 @@ const runtime = createRuntime({
|
|
|
66
66
|
| `@cognidesk/ui` | Prebuilt UI components |
|
|
67
67
|
| `@cognidesk/storage` | Storage adapters |
|
|
68
68
|
| `@cognidesk/otel` | OpenTelemetry instrumentation |
|
|
69
|
-
| `@cognidesk/
|
|
69
|
+
| `@cognidesk/integrations` | External Provider Integrations with category/provider subpaths, such as `@cognidesk/integrations/email/gmail`, `@cognidesk/integrations/voice/openai`, and `@cognidesk/integrations/voice/elevenlabs` |
|
|
70
70
|
| `@cognidesk/voice-websocket` | Voice WebSocket adapter |
|
|
71
71
|
| `@cognidesk/journey-index-json` | JSON-based journey index |
|
|
72
72
|
|
|
73
73
|
## Quick start
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
pnpm add @cognidesk/core @cognidesk/http @cognidesk/storage @libsql/client
|
|
76
|
+
pnpm add @cognidesk/core @cognidesk/http @cognidesk/model @cognidesk/storage @libsql/client @ai-sdk/openai zod
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
Read the full [Quick Start guide →](https://cognidesk.cognilabz.com/getting-started/quick-start/)
|
|
80
80
|
|
|
81
81
|
## Demo
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Repository development uses Node.js 24 and the pinned pnpm version from
|
|
84
|
+
`package.json`:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
corepack enable
|
|
88
|
+
pnpm install
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Run the flight support demo locally:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cp apps/flight-demo/config.openrouter.example.json apps/flight-demo/config.json
|
|
95
|
+
export OPENROUTER_KEY=sk-or-...
|
|
96
|
+
pnpm --filter @cognidesk/flight-demo ingest:knowledge
|
|
97
|
+
pnpm demo
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Open `http://localhost:5173` for the demo frontend,
|
|
101
|
+
`http://localhost:8787/api` for the API, and `http://localhost:3000` for
|
|
102
|
+
Cognidesk Studio. The default local Studio login is
|
|
103
|
+
`admin@local.cognidesk.dev` / `cognidesk-studio-admin`.
|
|
104
|
+
|
|
105
|
+
Docker uses the same config and model credentials:
|
|
84
106
|
|
|
85
107
|
```bash
|
|
86
108
|
docker compose up --build
|
|
87
109
|
```
|
|
88
110
|
|
|
89
|
-
|
|
111
|
+
Use the OpenTelemetry compose file when you want Grafana, Tempo, Prometheus,
|
|
112
|
+
Loki, and Promtail:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
docker compose -f docker-compose.otel.yml up --build
|
|
116
|
+
```
|
|
90
117
|
|
|
91
118
|
## Development
|
|
92
119
|
|
|
93
120
|
```bash
|
|
94
|
-
pnpm install
|
|
95
121
|
pnpm check
|
|
96
122
|
```
|
|
97
123
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChannelEventActor, ChannelEventActorType, NormalizedChannelPayloadInput, HandleChannelEventInput, ChannelEventEnvelopeInput, ChannelEventIdentity, ConversationChannelInput, ChannelEventKind, ChannelEventNature, ChannelEventDirection, ChannelEventIntent, ChannelEventSourceEvidence, CreateRuntimeConversationInput, ConversationRecord, HandleChannelEventResult, HandleUserMessageInput, HandleUserMessageResult, SubmitWidgetInput, RuntimeEvent, CustomRuntimeEventDefinition, JourneyEventDefinition, EmitJourneyEventResult, EmitIntermediateMessageInput, EmitGeneratedPreambleInput, CompactConversationInput, CompactConversationResult, RequestHandoffInput, ResumeConversationInput, ResolveChannelOutputInput, ResolveChannelOutputResult, StartVoiceConversationInput, StartVoiceResult, StartVoiceSegmentInput, ReplayConversationInput, ReplayConversationResult, RuntimeSnapshot, CognideskRuntime, VoiceSocketMetadata } from '@cognidesk/core';
|
|
1
|
+
import { ChannelEventActor, ChannelEventActorType, NormalizedChannelPayloadInput, HandleChannelEventInput, ChannelEventEnvelopeInput, ChannelEventIdentity, ConversationChannelInput, ChannelEventKind, ChannelEventNature, ChannelEventDirection, ChannelEventIntent, ChannelEventSourceEvidence, CreateRuntimeConversationInput, ConversationRecord, ListRuntimeConversationsOptions, HandleChannelEventResult, HandleUserMessageInput, HandleUserMessageResult, SubmitWidgetInput, RuntimeEvent, CustomRuntimeEventDefinition, JourneyEventDefinition, EmitJourneyEventResult, EmitIntermediateMessageInput, EmitGeneratedPreambleInput, CompactConversationInput, CompactConversationResult, RequestHandoffInput, ResumeConversationInput, ResolveChannelOutputInput, ResolveChannelOutputResult, StartVoiceConversationInput, StartVoiceResult, StartVoiceSegmentInput, ReplayConversationInput, ReplayConversationResult, RuntimeSnapshot, CognideskRuntime, VoiceSocketMetadata } from '@cognidesk/core';
|
|
2
2
|
export { ChannelEventActor, ChannelEventActorType, ChannelEventBindingOutcome, ChannelEventDirection, ChannelEventEnvelope, ChannelEventEnvelopeInput, ChannelEventHandlingDisposition, ChannelEventIdentity, ChannelEventIntakeResult, ChannelEventIntakeStatus, ChannelEventIntent, ChannelEventKind, ChannelEventNature, ChannelEventSourceEvidence, ChannelEventSourceType, ChannelOutputDeliveryMode, ChannelOutputIntent, ChannelOutputIntentInput, ChannelOutputIntentKind, ChannelOutputResolution, ChannelOutputResolutionDecision, ChannelOutputResolutionOutcome, ChannelOutputResolutionPayload, ChannelOutputResolutionStatus, ChannelSourceEvidence, HandleChannelEventInput, HandleChannelEventResult, NormalizedChannelPayload, NormalizedChannelPayloadInput, ResolveChannelOutputInput, ResolveChannelOutputResult } from '@cognidesk/core';
|
|
3
3
|
|
|
4
4
|
type ChannelEventActorInput = ChannelEventActor | ChannelEventActorType;
|
|
@@ -112,6 +112,7 @@ declare function createChannelHandoffReviewEventInput<TPayload = NormalizedChann
|
|
|
112
112
|
|
|
113
113
|
interface CognideskHttpRuntime {
|
|
114
114
|
createConversation(input: CreateRuntimeConversationInput): Promise<ConversationRecord>;
|
|
115
|
+
listConversations?(input?: ListRuntimeConversationsOptions): Promise<ConversationRecord[]>;
|
|
115
116
|
handleChannelEvent?(input: HandleChannelEventInput): Promise<HandleChannelEventResult>;
|
|
116
117
|
handleUserMessage(input: HandleUserMessageInput): Promise<HandleUserMessageResult>;
|
|
117
118
|
submitWidget?(input: SubmitWidgetInput): Promise<RuntimeEvent>;
|
package/dist/index.js
CHANGED
|
@@ -109,10 +109,10 @@ function stripBasePath(pathname, basePath) {
|
|
|
109
109
|
if (!pathname.startsWith(`${basePath}/`)) return null;
|
|
110
110
|
return pathname.slice(basePath.length);
|
|
111
111
|
}
|
|
112
|
-
function parseOptionalInteger(value) {
|
|
112
|
+
function parseOptionalInteger(value, name = "after") {
|
|
113
113
|
if (value === null || value === "") return void 0;
|
|
114
114
|
if (!/^(0|[1-9]\d*)$/.test(value)) {
|
|
115
|
-
throw new HttpInputError(
|
|
115
|
+
throw new HttpInputError(`${name} must be a non-negative integer.`);
|
|
116
116
|
}
|
|
117
117
|
return Number(value);
|
|
118
118
|
}
|
|
@@ -760,6 +760,30 @@ function createCognideskHttpHandler(options) {
|
|
|
760
760
|
}
|
|
761
761
|
const authorizationResponse = await authorizeRequest(options, { request, url, path }, responseOptions);
|
|
762
762
|
if (authorizationResponse) return authorizationResponse;
|
|
763
|
+
if (request.method === "GET" && path === "/conversations") {
|
|
764
|
+
if (!options.runtime.listConversations) return json({ error: "Conversation listing is not supported by this runtime" }, 501, responseOptions);
|
|
765
|
+
const limit = parseOptionalInteger(url.searchParams.get("limit"), "limit");
|
|
766
|
+
const agentId = optionalSearchString(url.searchParams, "agentId");
|
|
767
|
+
const beforeUpdatedAt = optionalSearchString(url.searchParams, "beforeUpdatedAt") ?? optionalSearchString(url.searchParams, "before");
|
|
768
|
+
const afterUpdatedAt = optionalSearchString(url.searchParams, "afterUpdatedAt") ?? optionalSearchString(url.searchParams, "after");
|
|
769
|
+
const beforeId = optionalSearchString(url.searchParams, "beforeId");
|
|
770
|
+
const afterId = optionalSearchString(url.searchParams, "afterId");
|
|
771
|
+
if (beforeId && !beforeUpdatedAt || beforeUpdatedAt && beforeId === void 0 && url.searchParams.has("beforeId")) {
|
|
772
|
+
throw new HttpInputError("beforeUpdatedAt and beforeId must be provided together.");
|
|
773
|
+
}
|
|
774
|
+
if (afterId && !afterUpdatedAt || afterUpdatedAt && afterId === void 0 && url.searchParams.has("afterId")) {
|
|
775
|
+
throw new HttpInputError("afterUpdatedAt and afterId must be provided together.");
|
|
776
|
+
}
|
|
777
|
+
const conversations = await options.runtime.listConversations({
|
|
778
|
+
...agentId ? { agentId } : {},
|
|
779
|
+
...beforeUpdatedAt && beforeId ? { before: { updatedAt: beforeUpdatedAt, id: beforeId } } : {},
|
|
780
|
+
...afterUpdatedAt && afterId ? { after: { updatedAt: afterUpdatedAt, id: afterId } } : {},
|
|
781
|
+
...beforeUpdatedAt && !beforeId ? { beforeUpdatedAt } : {},
|
|
782
|
+
...afterUpdatedAt && !afterId ? { afterUpdatedAt } : {},
|
|
783
|
+
...limit !== void 0 ? { limit } : {}
|
|
784
|
+
});
|
|
785
|
+
return json({ conversations }, 200, responseOptions);
|
|
786
|
+
}
|
|
763
787
|
if (request.method === "POST" && path === "/conversations") {
|
|
764
788
|
const body = await readObject(request);
|
|
765
789
|
const agentId = optionalString(body, "agentId") ?? options.agentId;
|
|
@@ -1040,6 +1064,12 @@ function createCognideskHttpHandler(options) {
|
|
|
1040
1064
|
}
|
|
1041
1065
|
};
|
|
1042
1066
|
}
|
|
1067
|
+
function optionalSearchString(params, key) {
|
|
1068
|
+
const value = params.get(key);
|
|
1069
|
+
if (value === null) return void 0;
|
|
1070
|
+
const trimmed = value.trim();
|
|
1071
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
1072
|
+
}
|
|
1043
1073
|
export {
|
|
1044
1074
|
createChannelEventInput,
|
|
1045
1075
|
createChannelEventRequestBody,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognidesk/http",
|
|
3
|
-
"version": "0.0.3-dev.
|
|
3
|
+
"version": "0.0.3-dev.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"lint": "tsc -p tsconfig.json --noEmit"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@cognidesk/core": "0.0.3-dev.
|
|
21
|
+
"@cognidesk/core": "0.0.3-dev.9"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsup": "^8.5.0",
|