@kokimoki/app 1.14.0 → 1.15.1
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/fields.d.ts +95 -0
- package/dist/fields.js +152 -0
- package/dist/kokimoki-client-refactored.d.ts +68 -0
- package/dist/kokimoki-client-refactored.js +394 -0
- package/dist/kokimoki-client.d.ts +6 -0
- package/dist/kokimoki-client.js +14 -0
- package/dist/kokimoki-schema.d.ts +84 -0
- package/dist/kokimoki-schema.js +163 -0
- package/dist/kokimoki-store.js +1 -1
- package/dist/kokimoki-transaction.js +1 -1
- package/dist/kokimoki.min.d.ts +6 -0
- package/dist/kokimoki.min.js +15 -1
- package/dist/kokimoki.min.js.map +1 -1
- package/dist/message-queue.d.ts +8 -0
- package/dist/message-queue.js +19 -0
- package/dist/synced-schema.d.ts +59 -0
- package/dist/synced-schema.js +84 -0
- package/dist/synced-store.d.ts +7 -0
- package/dist/synced-store.js +9 -0
- package/dist/synced-types.d.ts +38 -0
- package/dist/synced-types.js +68 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/ws-message-type copy.d.ts +6 -0
- package/dist/ws-message-type copy.js +7 -0
- package/package.json +1 -1
|
@@ -131,6 +131,12 @@ export declare class KokimokiClient<ClientContextT = any> extends KokimokiClient
|
|
|
131
131
|
sendWebhook<T>(event: string, data: T): Promise<{
|
|
132
132
|
jobId: string;
|
|
133
133
|
}>;
|
|
134
|
+
/**
|
|
135
|
+
* Generic AI chat endpoint: send a system prompt (and optional user prompt) to get a response.
|
|
136
|
+
*/
|
|
137
|
+
chat(systemPrompt: string, userPrompt?: string, temperature?: number, maxTokens?: number): Promise<{
|
|
138
|
+
content: string;
|
|
139
|
+
}>;
|
|
134
140
|
/**
|
|
135
141
|
* Use AI to apply prompt to an image
|
|
136
142
|
*/
|
package/dist/kokimoki-client.js
CHANGED
|
@@ -711,6 +711,20 @@ export class KokimokiClient extends EventEmitter {
|
|
|
711
711
|
});
|
|
712
712
|
return await res.json();
|
|
713
713
|
}
|
|
714
|
+
/**
|
|
715
|
+
* Generic AI chat endpoint: send a system prompt (and optional user prompt) to get a response.
|
|
716
|
+
*/
|
|
717
|
+
async chat(systemPrompt, userPrompt, temperature, maxTokens) {
|
|
718
|
+
const res = await fetch(`${this._apiUrl}/ai/chat`, {
|
|
719
|
+
method: "POST",
|
|
720
|
+
headers: this.apiHeaders,
|
|
721
|
+
body: JSON.stringify({ systemPrompt, userPrompt, temperature, maxTokens }),
|
|
722
|
+
});
|
|
723
|
+
if (!res.ok) {
|
|
724
|
+
throw await res.json();
|
|
725
|
+
}
|
|
726
|
+
return await res.json();
|
|
727
|
+
}
|
|
714
728
|
/**
|
|
715
729
|
* Use AI to apply prompt to an image
|
|
716
730
|
*/
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export declare namespace KokimokiSchema {
|
|
2
|
+
abstract class Generic<T> {
|
|
3
|
+
abstract get defaultValue(): T;
|
|
4
|
+
abstract set defaultValue(value: T);
|
|
5
|
+
}
|
|
6
|
+
class Number extends Generic<number> {
|
|
7
|
+
defaultValue: number;
|
|
8
|
+
constructor(defaultValue?: number);
|
|
9
|
+
}
|
|
10
|
+
function number(defaultValue?: number): Number;
|
|
11
|
+
class String extends Generic<string> {
|
|
12
|
+
defaultValue: string;
|
|
13
|
+
constructor(defaultValue?: string);
|
|
14
|
+
}
|
|
15
|
+
function string(defaultValue?: string): String;
|
|
16
|
+
class Boolean extends Generic<boolean> {
|
|
17
|
+
defaultValue: boolean;
|
|
18
|
+
constructor(defaultValue?: boolean);
|
|
19
|
+
}
|
|
20
|
+
function boolean(defaultValue?: boolean): Boolean;
|
|
21
|
+
class Struct<Data extends Record<string, Generic<unknown>>> extends Generic<{
|
|
22
|
+
[key in keyof Data]: Data[key]["defaultValue"];
|
|
23
|
+
}> {
|
|
24
|
+
fields: Data;
|
|
25
|
+
constructor(fields: Data);
|
|
26
|
+
get defaultValue(): {
|
|
27
|
+
[key in keyof Data]: Data[key]["defaultValue"];
|
|
28
|
+
};
|
|
29
|
+
set defaultValue(value: {
|
|
30
|
+
[key in keyof Data]: Data[key]["defaultValue"];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function struct<Data extends Record<string, Generic<unknown>>>(schema: Data): Struct<Data>;
|
|
34
|
+
class Dict<T extends Generic<unknown>> {
|
|
35
|
+
schema: T;
|
|
36
|
+
defaultValue: {
|
|
37
|
+
[key: string]: T["defaultValue"];
|
|
38
|
+
};
|
|
39
|
+
constructor(schema: T, defaultValue?: {
|
|
40
|
+
[key: string]: T["defaultValue"];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function dict<T extends Generic<unknown>>(schema: T, defaultValue?: {
|
|
44
|
+
[key: string]: T["defaultValue"];
|
|
45
|
+
}): Dict<T>;
|
|
46
|
+
class List<T extends Generic<unknown>> extends Generic<T["defaultValue"][]> {
|
|
47
|
+
schema: T;
|
|
48
|
+
defaultValue: T["defaultValue"][];
|
|
49
|
+
constructor(schema: T, defaultValue?: T["defaultValue"][]);
|
|
50
|
+
}
|
|
51
|
+
function list<T extends Generic<unknown>>(schema: T, defaultValue?: T["defaultValue"][]): List<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Nullable
|
|
54
|
+
*/
|
|
55
|
+
class Nullable<T extends Generic<unknown>> extends Generic<T["defaultValue"] | null> {
|
|
56
|
+
schema: T;
|
|
57
|
+
defaultValue: T["defaultValue"] | null;
|
|
58
|
+
constructor(schema: T, defaultValue: T["defaultValue"] | null);
|
|
59
|
+
}
|
|
60
|
+
function nullable<T extends Generic<unknown>>(schema: T, defaultValue?: T["defaultValue"] | null): Nullable<T>;
|
|
61
|
+
class StringEnum<T extends readonly string[]> extends Generic<string> {
|
|
62
|
+
readonly options: T;
|
|
63
|
+
defaultValue: T[number];
|
|
64
|
+
constructor(options: T, defaultValue: T[number]);
|
|
65
|
+
}
|
|
66
|
+
function stringEnum<T extends readonly string[]>(options: T, defaultValue: T[number]): StringEnum<T>;
|
|
67
|
+
class StringConst<T extends string> extends Generic<string> {
|
|
68
|
+
readonly defaultValue: T;
|
|
69
|
+
constructor(defaultValue: T);
|
|
70
|
+
}
|
|
71
|
+
function stringConst<T extends string>(defaultValue: T): StringConst<T>;
|
|
72
|
+
class AnyOf<T extends readonly Generic<unknown>[]> extends Generic<T[number]["defaultValue"]> {
|
|
73
|
+
readonly schemas: T;
|
|
74
|
+
defaultValue: T[number]["defaultValue"];
|
|
75
|
+
constructor(schemas: T, defaultValue: T[number]["defaultValue"]);
|
|
76
|
+
}
|
|
77
|
+
function anyOf<T extends readonly Generic<unknown>[]>(schemas: T, defaultValue: T[number]["defaultValue"]): AnyOf<T>;
|
|
78
|
+
class Optional<T extends Generic<unknown>> extends Generic<T["defaultValue"] | undefined> {
|
|
79
|
+
schema: T;
|
|
80
|
+
defaultValue: T["defaultValue"] | undefined;
|
|
81
|
+
constructor(schema: T, defaultValue?: T["defaultValue"] | undefined);
|
|
82
|
+
}
|
|
83
|
+
function optional<T extends Generic<unknown>>(schema: T, defaultValue?: T["defaultValue"] | undefined): Optional<T>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export var KokimokiSchema;
|
|
2
|
+
(function (KokimokiSchema) {
|
|
3
|
+
class Generic {
|
|
4
|
+
}
|
|
5
|
+
KokimokiSchema.Generic = Generic;
|
|
6
|
+
class Number extends Generic {
|
|
7
|
+
defaultValue;
|
|
8
|
+
constructor(defaultValue = 0) {
|
|
9
|
+
super();
|
|
10
|
+
this.defaultValue = defaultValue;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
KokimokiSchema.Number = Number;
|
|
14
|
+
function number(defaultValue = 0) {
|
|
15
|
+
return new Number(defaultValue);
|
|
16
|
+
}
|
|
17
|
+
KokimokiSchema.number = number;
|
|
18
|
+
class String extends Generic {
|
|
19
|
+
defaultValue;
|
|
20
|
+
constructor(defaultValue = "") {
|
|
21
|
+
super();
|
|
22
|
+
this.defaultValue = defaultValue;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
KokimokiSchema.String = String;
|
|
26
|
+
function string(defaultValue = "") {
|
|
27
|
+
return new String(defaultValue);
|
|
28
|
+
}
|
|
29
|
+
KokimokiSchema.string = string;
|
|
30
|
+
class Boolean extends Generic {
|
|
31
|
+
defaultValue;
|
|
32
|
+
constructor(defaultValue = false) {
|
|
33
|
+
super();
|
|
34
|
+
this.defaultValue = defaultValue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
KokimokiSchema.Boolean = Boolean;
|
|
38
|
+
function boolean(defaultValue = false) {
|
|
39
|
+
return new Boolean(defaultValue);
|
|
40
|
+
}
|
|
41
|
+
KokimokiSchema.boolean = boolean;
|
|
42
|
+
class Struct extends Generic {
|
|
43
|
+
fields;
|
|
44
|
+
constructor(fields) {
|
|
45
|
+
super();
|
|
46
|
+
this.fields = fields;
|
|
47
|
+
}
|
|
48
|
+
get defaultValue() {
|
|
49
|
+
return Object.entries(this.fields).reduce((acc, [key, field]) => {
|
|
50
|
+
acc[key] = field.defaultValue;
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
53
|
+
}
|
|
54
|
+
set defaultValue(value) {
|
|
55
|
+
for (const [key, field] of Object.entries(this.fields)) {
|
|
56
|
+
field.defaultValue = value[key];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
KokimokiSchema.Struct = Struct;
|
|
61
|
+
function struct(schema) {
|
|
62
|
+
return new Struct(schema);
|
|
63
|
+
}
|
|
64
|
+
KokimokiSchema.struct = struct;
|
|
65
|
+
class Dict {
|
|
66
|
+
schema;
|
|
67
|
+
defaultValue;
|
|
68
|
+
constructor(schema, defaultValue = {}) {
|
|
69
|
+
this.schema = schema;
|
|
70
|
+
this.defaultValue = defaultValue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
KokimokiSchema.Dict = Dict;
|
|
74
|
+
function dict(schema, defaultValue = {}) {
|
|
75
|
+
return new Dict(schema, defaultValue);
|
|
76
|
+
}
|
|
77
|
+
KokimokiSchema.dict = dict;
|
|
78
|
+
class List extends Generic {
|
|
79
|
+
schema;
|
|
80
|
+
defaultValue;
|
|
81
|
+
constructor(schema, defaultValue = []) {
|
|
82
|
+
super();
|
|
83
|
+
this.schema = schema;
|
|
84
|
+
this.defaultValue = defaultValue;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
KokimokiSchema.List = List;
|
|
88
|
+
function list(schema, defaultValue = []) {
|
|
89
|
+
return new List(schema, defaultValue);
|
|
90
|
+
}
|
|
91
|
+
KokimokiSchema.list = list;
|
|
92
|
+
/**
|
|
93
|
+
* Nullable
|
|
94
|
+
*/
|
|
95
|
+
class Nullable extends Generic {
|
|
96
|
+
schema;
|
|
97
|
+
defaultValue;
|
|
98
|
+
constructor(schema, defaultValue) {
|
|
99
|
+
super();
|
|
100
|
+
this.schema = schema;
|
|
101
|
+
this.defaultValue = defaultValue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
KokimokiSchema.Nullable = Nullable;
|
|
105
|
+
function nullable(schema, defaultValue = null) {
|
|
106
|
+
return new Nullable(schema, defaultValue);
|
|
107
|
+
}
|
|
108
|
+
KokimokiSchema.nullable = nullable;
|
|
109
|
+
class StringEnum extends Generic {
|
|
110
|
+
options;
|
|
111
|
+
defaultValue;
|
|
112
|
+
constructor(options, defaultValue) {
|
|
113
|
+
super();
|
|
114
|
+
this.options = options;
|
|
115
|
+
this.defaultValue = defaultValue;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
KokimokiSchema.StringEnum = StringEnum;
|
|
119
|
+
function stringEnum(options, defaultValue) {
|
|
120
|
+
return new StringEnum(options, defaultValue);
|
|
121
|
+
}
|
|
122
|
+
KokimokiSchema.stringEnum = stringEnum;
|
|
123
|
+
class StringConst extends Generic {
|
|
124
|
+
defaultValue;
|
|
125
|
+
constructor(defaultValue) {
|
|
126
|
+
super();
|
|
127
|
+
this.defaultValue = defaultValue;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
KokimokiSchema.StringConst = StringConst;
|
|
131
|
+
function stringConst(defaultValue) {
|
|
132
|
+
return new StringConst(defaultValue);
|
|
133
|
+
}
|
|
134
|
+
KokimokiSchema.stringConst = stringConst;
|
|
135
|
+
class AnyOf extends Generic {
|
|
136
|
+
schemas;
|
|
137
|
+
defaultValue;
|
|
138
|
+
constructor(schemas, defaultValue) {
|
|
139
|
+
super();
|
|
140
|
+
this.schemas = schemas;
|
|
141
|
+
this.defaultValue = defaultValue;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
KokimokiSchema.AnyOf = AnyOf;
|
|
145
|
+
function anyOf(schemas, defaultValue) {
|
|
146
|
+
return new AnyOf(schemas, defaultValue);
|
|
147
|
+
}
|
|
148
|
+
KokimokiSchema.anyOf = anyOf;
|
|
149
|
+
class Optional extends Generic {
|
|
150
|
+
schema;
|
|
151
|
+
defaultValue;
|
|
152
|
+
constructor(schema, defaultValue = undefined) {
|
|
153
|
+
super();
|
|
154
|
+
this.schema = schema;
|
|
155
|
+
this.defaultValue = defaultValue;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
KokimokiSchema.Optional = Optional;
|
|
159
|
+
function optional(schema, defaultValue = undefined) {
|
|
160
|
+
return new Optional(schema, defaultValue);
|
|
161
|
+
}
|
|
162
|
+
KokimokiSchema.optional = optional;
|
|
163
|
+
})(KokimokiSchema || (KokimokiSchema = {}));
|
package/dist/kokimoki-store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Y from "yjs";
|
|
2
|
-
import { proxy as yjsProxy } from "valtio";
|
|
2
|
+
import { proxy as yjsProxy } from "valtio/vanilla";
|
|
3
3
|
import { bind as yjsBind } from "valtio-yjs";
|
|
4
4
|
import { RoomSubscriptionMode } from "./room-subscription-mode";
|
|
5
5
|
export class KokimokiStore {
|
package/dist/kokimoki.min.d.ts
CHANGED
|
@@ -202,6 +202,12 @@ declare class KokimokiClient<ClientContextT = any> extends KokimokiClient_base {
|
|
|
202
202
|
sendWebhook<T>(event: string, data: T): Promise<{
|
|
203
203
|
jobId: string;
|
|
204
204
|
}>;
|
|
205
|
+
/**
|
|
206
|
+
* Generic AI chat endpoint: send a system prompt (and optional user prompt) to get a response.
|
|
207
|
+
*/
|
|
208
|
+
chat(systemPrompt: string, userPrompt?: string, temperature?: number, maxTokens?: number): Promise<{
|
|
209
|
+
content: string;
|
|
210
|
+
}>;
|
|
205
211
|
/**
|
|
206
212
|
* Use AI to apply prompt to an image
|
|
207
213
|
*/
|
package/dist/kokimoki.min.js
CHANGED
|
@@ -486,7 +486,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
|
|
486
486
|
var eventsExports = events.exports;
|
|
487
487
|
var EventEmitter$1 = /*@__PURE__*/getDefaultExportFromCjs(eventsExports);
|
|
488
488
|
|
|
489
|
-
const KOKIMOKI_APP_VERSION = "1.
|
|
489
|
+
const KOKIMOKI_APP_VERSION = "1.15.1";
|
|
490
490
|
|
|
491
491
|
/**
|
|
492
492
|
* Utility module to work with key-value stores.
|
|
@@ -15458,6 +15458,20 @@ class KokimokiClient extends EventEmitter$1 {
|
|
|
15458
15458
|
});
|
|
15459
15459
|
return await res.json();
|
|
15460
15460
|
}
|
|
15461
|
+
/**
|
|
15462
|
+
* Generic AI chat endpoint: send a system prompt (and optional user prompt) to get a response.
|
|
15463
|
+
*/
|
|
15464
|
+
async chat(systemPrompt, userPrompt, temperature, maxTokens) {
|
|
15465
|
+
const res = await fetch(`${this._apiUrl}/ai/chat`, {
|
|
15466
|
+
method: "POST",
|
|
15467
|
+
headers: this.apiHeaders,
|
|
15468
|
+
body: JSON.stringify({ systemPrompt, userPrompt, temperature, maxTokens }),
|
|
15469
|
+
});
|
|
15470
|
+
if (!res.ok) {
|
|
15471
|
+
throw await res.json();
|
|
15472
|
+
}
|
|
15473
|
+
return await res.json();
|
|
15474
|
+
}
|
|
15461
15475
|
/**
|
|
15462
15476
|
* Use AI to apply prompt to an image
|
|
15463
15477
|
*/
|