@ainetwork/adk-provider-memory-inmemory 0.1.4 → 0.1.5
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/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/implements/session.memory.ts +4 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -45,6 +45,7 @@ var InMemorySession = class {
|
|
|
45
45
|
const res = this.sessions.get(key);
|
|
46
46
|
if (res) {
|
|
47
47
|
const sessionObject = {
|
|
48
|
+
title: res.title,
|
|
48
49
|
chats: Object.fromEntries(res.chats)
|
|
49
50
|
};
|
|
50
51
|
return sessionObject;
|
|
@@ -58,9 +59,10 @@ var InMemorySession = class {
|
|
|
58
59
|
this.userSessionIndex.set(userId, /* @__PURE__ */ new Set());
|
|
59
60
|
}
|
|
60
61
|
if (!this.sessions.has(key)) {
|
|
61
|
-
this.sessions.set(key, { chats: /* @__PURE__ */ new Map() });
|
|
62
|
+
this.sessions.set(key, { title, chats: /* @__PURE__ */ new Map() });
|
|
62
63
|
const metadata = {
|
|
63
64
|
sessionId,
|
|
65
|
+
title,
|
|
64
66
|
createdAt: now,
|
|
65
67
|
updatedAt: now
|
|
66
68
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../implements/session.memory.ts","../implements/intent.memory.ts"],"sourcesContent":["export { InMemorySession } from \"./implements/session.memory\";\nexport { InMemoryIntent } from \"./implements/intent.memory\";","import { randomUUID } from \"node:crypto\";\nimport type { ChatObject, SessionObject, SessionMetadata } from \"@ainetwork/adk/types/memory\";\nimport { ISessionMemory } from \"@ainetwork/adk/modules\";\n\ntype InMemorySessionObject = {\n chats: Map<string, ChatObject>\n}\n\ntype InMemorySessionMetadata = {\n sessionId: string;\n title?: string;\n updatedAt: number;\n createdAt: number;\n}\n\nexport class InMemorySession implements ISessionMemory {\n\tpublic sessions: Map<string, InMemorySessionObject> = new Map();\n public userSessionIndex: Map<string, Set<InMemorySessionMetadata>> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n private generateKey(userId: string, sessionId: string) {\n return `${userId}:${sessionId}`;\n }\n\n public async getSession(userId: string, sessionId: string): Promise<SessionObject | undefined> {\n const key = this.generateKey(userId, sessionId);\n const res = this.sessions.get(key);\n if (res) {\n const sessionObject: SessionObject = {\n chats: Object.fromEntries(res.chats)\n };\n return sessionObject;\n }\n return undefined;\n };\n\n\tpublic async createSession(userId: string, sessionId: string, title: string): Promise<SessionMetadata> {\n const now = Date.now();\n const key = this.generateKey(userId, sessionId);\n if (!this.userSessionIndex.has(userId)) {\n this.userSessionIndex.set(userId, new Set());\n }\n if (!this.sessions.has(key)) {\n this.sessions.set(key, { chats: new Map() });\n const metadata: InMemorySessionMetadata = {\n sessionId, createdAt: now, updatedAt: now,\n }\n this.userSessionIndex.get(userId)?.add(metadata);\n }\n\n return { title, sessionId, updatedAt: now };\n };\n\n\tpublic async addChatToSession(userId: string, sessionId: string, chat: ChatObject): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n await this.createSession(userId, sessionId, \"New chat\");\n const newChatId = randomUUID();\n this.sessions.get(key)?.chats.set(newChatId, chat);\n };\n\n\tpublic async deleteSession(userId: string, sessionId: string): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n this.sessions.delete(key);\n this.userSessionIndex.delete(sessionId);\n };\n\n\tpublic async listSessions(userId: string): Promise<SessionMetadata[]> {\n const sessions = this.userSessionIndex.get(userId);\n if (sessions) {\n return Array.from(sessions);\n }\n return [];\n };\n}","import { randomUUID } from \"node:crypto\";\nimport type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryIntent implements IIntentMemory {\n\tpublic intents: Map<string, Intent> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.intents.get(intentId);\n };\n\n\tpublic async saveIntent(intent: Intent): Promise<void> {\n const newId = randomUUID();\n this.intents.set(newId, intent);\n };\n\n\tpublic async updateIntent(intentId: string, intent: Intent): Promise<void> {\n this.intents.set(intentId, intent);\n };\n\n\tpublic async deleteIntent(intentId: string): Promise<void> {\n this.intents.delete(intentId);\n };\n\n\tpublic async listIntents(): Promise<Intent[]> {\n return Array.from(this.intents.values());\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAA2B;
|
|
1
|
+
{"version":3,"sources":["../index.ts","../implements/session.memory.ts","../implements/intent.memory.ts"],"sourcesContent":["export { InMemorySession } from \"./implements/session.memory\";\nexport { InMemoryIntent } from \"./implements/intent.memory\";","import { randomUUID } from \"node:crypto\";\nimport type { ChatObject, SessionObject, SessionMetadata } from \"@ainetwork/adk/types/memory\";\nimport { ISessionMemory } from \"@ainetwork/adk/modules\";\n\ntype InMemorySessionObject = {\n title?: string;\n chats: Map<string, ChatObject>\n}\n\ntype InMemorySessionMetadata = {\n sessionId: string;\n title?: string;\n updatedAt: number;\n createdAt: number;\n}\n\nexport class InMemorySession implements ISessionMemory {\n\tpublic sessions: Map<string, InMemorySessionObject> = new Map();\n public userSessionIndex: Map<string, Set<InMemorySessionMetadata>> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n private generateKey(userId: string, sessionId: string) {\n return `${userId}:${sessionId}`;\n }\n\n public async getSession(userId: string, sessionId: string): Promise<SessionObject | undefined> {\n const key = this.generateKey(userId, sessionId);\n const res = this.sessions.get(key);\n if (res) {\n const sessionObject: SessionObject = {\n title: res.title,\n chats: Object.fromEntries(res.chats)\n };\n return sessionObject;\n }\n return undefined;\n };\n\n\tpublic async createSession(userId: string, sessionId: string, title: string): Promise<SessionMetadata> {\n const now = Date.now();\n const key = this.generateKey(userId, sessionId);\n if (!this.userSessionIndex.has(userId)) {\n this.userSessionIndex.set(userId, new Set());\n }\n if (!this.sessions.has(key)) {\n this.sessions.set(key, { title, chats: new Map() });\n const metadata: InMemorySessionMetadata = {\n sessionId, title, createdAt: now, updatedAt: now,\n }\n this.userSessionIndex.get(userId)?.add(metadata);\n }\n\n return { title, sessionId, updatedAt: now };\n };\n\n\tpublic async addChatToSession(userId: string, sessionId: string, chat: ChatObject): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n await this.createSession(userId, sessionId, \"New chat\");\n const newChatId = randomUUID();\n this.sessions.get(key)?.chats.set(newChatId, chat);\n };\n\n\tpublic async deleteSession(userId: string, sessionId: string): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n this.sessions.delete(key);\n this.userSessionIndex.delete(sessionId);\n };\n\n\tpublic async listSessions(userId: string): Promise<SessionMetadata[]> {\n const sessions = this.userSessionIndex.get(userId);\n if (sessions) {\n return Array.from(sessions);\n }\n return [];\n };\n}","import { randomUUID } from \"node:crypto\";\nimport type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryIntent implements IIntentMemory {\n\tpublic intents: Map<string, Intent> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.intents.get(intentId);\n };\n\n\tpublic async saveIntent(intent: Intent): Promise<void> {\n const newId = randomUUID();\n this.intents.set(newId, intent);\n };\n\n\tpublic async updateIntent(intentId: string, intent: Intent): Promise<void> {\n this.intents.set(intentId, intent);\n };\n\n\tpublic async deleteIntent(intentId: string): Promise<void> {\n this.intents.delete(intentId);\n };\n\n\tpublic async listIntents(): Promise<Intent[]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zC;AACF;","names":["import_node_crypto"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import { ChatObject, SessionObject, SessionMetadata, Intent } from '@ainetwork/a
|
|
|
2
2
|
import { ISessionMemory, IIntentMemory } from '@ainetwork/adk/modules';
|
|
3
3
|
|
|
4
4
|
type InMemorySessionObject = {
|
|
5
|
+
title?: string;
|
|
5
6
|
chats: Map<string, ChatObject>;
|
|
6
7
|
};
|
|
7
8
|
type InMemorySessionMetadata = {
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ChatObject, SessionObject, SessionMetadata, Intent } from '@ainetwork/a
|
|
|
2
2
|
import { ISessionMemory, IIntentMemory } from '@ainetwork/adk/modules';
|
|
3
3
|
|
|
4
4
|
type InMemorySessionObject = {
|
|
5
|
+
title?: string;
|
|
5
6
|
chats: Map<string, ChatObject>;
|
|
6
7
|
};
|
|
7
8
|
type InMemorySessionMetadata = {
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var InMemorySession = class {
|
|
|
18
18
|
const res = this.sessions.get(key);
|
|
19
19
|
if (res) {
|
|
20
20
|
const sessionObject = {
|
|
21
|
+
title: res.title,
|
|
21
22
|
chats: Object.fromEntries(res.chats)
|
|
22
23
|
};
|
|
23
24
|
return sessionObject;
|
|
@@ -31,9 +32,10 @@ var InMemorySession = class {
|
|
|
31
32
|
this.userSessionIndex.set(userId, /* @__PURE__ */ new Set());
|
|
32
33
|
}
|
|
33
34
|
if (!this.sessions.has(key)) {
|
|
34
|
-
this.sessions.set(key, { chats: /* @__PURE__ */ new Map() });
|
|
35
|
+
this.sessions.set(key, { title, chats: /* @__PURE__ */ new Map() });
|
|
35
36
|
const metadata = {
|
|
36
37
|
sessionId,
|
|
38
|
+
title,
|
|
37
39
|
createdAt: now,
|
|
38
40
|
updatedAt: now
|
|
39
41
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../implements/session.memory.ts","../implements/intent.memory.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { ChatObject, SessionObject, SessionMetadata } from \"@ainetwork/adk/types/memory\";\nimport { ISessionMemory } from \"@ainetwork/adk/modules\";\n\ntype InMemorySessionObject = {\n chats: Map<string, ChatObject>\n}\n\ntype InMemorySessionMetadata = {\n sessionId: string;\n title?: string;\n updatedAt: number;\n createdAt: number;\n}\n\nexport class InMemorySession implements ISessionMemory {\n\tpublic sessions: Map<string, InMemorySessionObject> = new Map();\n public userSessionIndex: Map<string, Set<InMemorySessionMetadata>> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n private generateKey(userId: string, sessionId: string) {\n return `${userId}:${sessionId}`;\n }\n\n public async getSession(userId: string, sessionId: string): Promise<SessionObject | undefined> {\n const key = this.generateKey(userId, sessionId);\n const res = this.sessions.get(key);\n if (res) {\n const sessionObject: SessionObject = {\n chats: Object.fromEntries(res.chats)\n };\n return sessionObject;\n }\n return undefined;\n };\n\n\tpublic async createSession(userId: string, sessionId: string, title: string): Promise<SessionMetadata> {\n const now = Date.now();\n const key = this.generateKey(userId, sessionId);\n if (!this.userSessionIndex.has(userId)) {\n this.userSessionIndex.set(userId, new Set());\n }\n if (!this.sessions.has(key)) {\n this.sessions.set(key, { chats: new Map() });\n const metadata: InMemorySessionMetadata = {\n sessionId, createdAt: now, updatedAt: now,\n }\n this.userSessionIndex.get(userId)?.add(metadata);\n }\n\n return { title, sessionId, updatedAt: now };\n };\n\n\tpublic async addChatToSession(userId: string, sessionId: string, chat: ChatObject): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n await this.createSession(userId, sessionId, \"New chat\");\n const newChatId = randomUUID();\n this.sessions.get(key)?.chats.set(newChatId, chat);\n };\n\n\tpublic async deleteSession(userId: string, sessionId: string): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n this.sessions.delete(key);\n this.userSessionIndex.delete(sessionId);\n };\n\n\tpublic async listSessions(userId: string): Promise<SessionMetadata[]> {\n const sessions = this.userSessionIndex.get(userId);\n if (sessions) {\n return Array.from(sessions);\n }\n return [];\n };\n}","import { randomUUID } from \"node:crypto\";\nimport type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryIntent implements IIntentMemory {\n\tpublic intents: Map<string, Intent> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.intents.get(intentId);\n };\n\n\tpublic async saveIntent(intent: Intent): Promise<void> {\n const newId = randomUUID();\n this.intents.set(newId, intent);\n };\n\n\tpublic async updateIntent(intentId: string, intent: Intent): Promise<void> {\n this.intents.set(intentId, intent);\n };\n\n\tpublic async deleteIntent(intentId: string): Promise<void> {\n this.intents.delete(intentId);\n };\n\n\tpublic async listIntents(): Promise<Intent[]> {\n return Array.from(this.intents.values());\n };\n}"],"mappings":";AAAA,SAAS,kBAAkB;
|
|
1
|
+
{"version":3,"sources":["../implements/session.memory.ts","../implements/intent.memory.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { ChatObject, SessionObject, SessionMetadata } from \"@ainetwork/adk/types/memory\";\nimport { ISessionMemory } from \"@ainetwork/adk/modules\";\n\ntype InMemorySessionObject = {\n title?: string;\n chats: Map<string, ChatObject>\n}\n\ntype InMemorySessionMetadata = {\n sessionId: string;\n title?: string;\n updatedAt: number;\n createdAt: number;\n}\n\nexport class InMemorySession implements ISessionMemory {\n\tpublic sessions: Map<string, InMemorySessionObject> = new Map();\n public userSessionIndex: Map<string, Set<InMemorySessionMetadata>> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n private generateKey(userId: string, sessionId: string) {\n return `${userId}:${sessionId}`;\n }\n\n public async getSession(userId: string, sessionId: string): Promise<SessionObject | undefined> {\n const key = this.generateKey(userId, sessionId);\n const res = this.sessions.get(key);\n if (res) {\n const sessionObject: SessionObject = {\n title: res.title,\n chats: Object.fromEntries(res.chats)\n };\n return sessionObject;\n }\n return undefined;\n };\n\n\tpublic async createSession(userId: string, sessionId: string, title: string): Promise<SessionMetadata> {\n const now = Date.now();\n const key = this.generateKey(userId, sessionId);\n if (!this.userSessionIndex.has(userId)) {\n this.userSessionIndex.set(userId, new Set());\n }\n if (!this.sessions.has(key)) {\n this.sessions.set(key, { title, chats: new Map() });\n const metadata: InMemorySessionMetadata = {\n sessionId, title, createdAt: now, updatedAt: now,\n }\n this.userSessionIndex.get(userId)?.add(metadata);\n }\n\n return { title, sessionId, updatedAt: now };\n };\n\n\tpublic async addChatToSession(userId: string, sessionId: string, chat: ChatObject): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n await this.createSession(userId, sessionId, \"New chat\");\n const newChatId = randomUUID();\n this.sessions.get(key)?.chats.set(newChatId, chat);\n };\n\n\tpublic async deleteSession(userId: string, sessionId: string): Promise<void> {\n const key = this.generateKey(userId, sessionId);\n this.sessions.delete(key);\n this.userSessionIndex.delete(sessionId);\n };\n\n\tpublic async listSessions(userId: string): Promise<SessionMetadata[]> {\n const sessions = this.userSessionIndex.get(userId);\n if (sessions) {\n return Array.from(sessions);\n }\n return [];\n };\n}","import { randomUUID } from \"node:crypto\";\nimport type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryIntent implements IIntentMemory {\n\tpublic intents: Map<string, Intent> = new Map();\n\n public async connect(): Promise<void> {}\n public async disconnect(): Promise<void> {}\n public isConnected(): boolean {\n return true;\n }\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.intents.get(intentId);\n };\n\n\tpublic async saveIntent(intent: Intent): Promise<void> {\n const newId = randomUUID();\n this.intents.set(newId, intent);\n };\n\n\tpublic async updateIntent(intentId: string, intent: Intent): Promise<void> {\n this.intents.set(intentId, intent);\n };\n\n\tpublic async deleteIntent(intentId: string): Promise<void> {\n this.intents.delete(intentId);\n };\n\n\tpublic async listIntents(): Promise<Intent[]> {\n return Array.from(this.intents.values());\n };\n}"],"mappings":";AAAA,SAAS,kBAAkB;AAgBpB,IAAM,kBAAN,MAAgD;AAAA,EAC/C,WAA+C,oBAAI,IAAI;AAAA,EACtD,mBAA8D,oBAAI,IAAI;AAAA,EAE7E,MAAa,UAAyB;AAAA,EAAC;AAAA,EACvC,MAAa,aAA4B;AAAA,EAAC;AAAA,EACnC,cAAuB;AAC5B,WAAO;AAAA,EACT;AAAA,EAEQ,YAAY,QAAgB,WAAmB;AACrD,WAAO,GAAG,MAAM,IAAI,SAAS;AAAA,EAC/B;AAAA,EAEA,MAAa,WAAW,QAAgB,WAAuD;AAC7F,UAAM,MAAM,KAAK,YAAY,QAAQ,SAAS;AAC9C,UAAM,MAAM,KAAK,SAAS,IAAI,GAAG;AACjC,QAAI,KAAK;AACP,YAAM,gBAA+B;AAAA,QACnC,OAAO,IAAI;AAAA,QACX,OAAO,OAAO,YAAY,IAAI,KAAK;AAAA,MACrC;AACA,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAAA,EAED,MAAa,cAAc,QAAgB,WAAmB,OAAyC;AACpG,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,MAAM,KAAK,YAAY,QAAQ,SAAS;AAC9C,QAAI,CAAC,KAAK,iBAAiB,IAAI,MAAM,GAAG;AACtC,WAAK,iBAAiB,IAAI,QAAQ,oBAAI,IAAI,CAAC;AAAA,IAC7C;AACA,QAAI,CAAC,KAAK,SAAS,IAAI,GAAG,GAAG;AAC3B,WAAK,SAAS,IAAI,KAAK,EAAE,OAAO,OAAO,oBAAI,IAAI,EAAE,CAAC;AAClD,YAAM,WAAoC;AAAA,QACxC;AAAA,QAAW;AAAA,QAAO,WAAW;AAAA,QAAK,WAAW;AAAA,MAC/C;AACA,WAAK,iBAAiB,IAAI,MAAM,GAAG,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WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC;AAAA,EACzC;AACF;","names":["randomUUID"]}
|
|
@@ -3,6 +3,7 @@ import type { ChatObject, SessionObject, SessionMetadata } from "@ainetwork/adk/
|
|
|
3
3
|
import { ISessionMemory } from "@ainetwork/adk/modules";
|
|
4
4
|
|
|
5
5
|
type InMemorySessionObject = {
|
|
6
|
+
title?: string;
|
|
6
7
|
chats: Map<string, ChatObject>
|
|
7
8
|
}
|
|
8
9
|
|
|
@@ -32,6 +33,7 @@ export class InMemorySession implements ISessionMemory {
|
|
|
32
33
|
const res = this.sessions.get(key);
|
|
33
34
|
if (res) {
|
|
34
35
|
const sessionObject: SessionObject = {
|
|
36
|
+
title: res.title,
|
|
35
37
|
chats: Object.fromEntries(res.chats)
|
|
36
38
|
};
|
|
37
39
|
return sessionObject;
|
|
@@ -46,9 +48,9 @@ export class InMemorySession implements ISessionMemory {
|
|
|
46
48
|
this.userSessionIndex.set(userId, new Set());
|
|
47
49
|
}
|
|
48
50
|
if (!this.sessions.has(key)) {
|
|
49
|
-
this.sessions.set(key, { chats: new Map() });
|
|
51
|
+
this.sessions.set(key, { title, chats: new Map() });
|
|
50
52
|
const metadata: InMemorySessionMetadata = {
|
|
51
|
-
sessionId, createdAt: now, updatedAt: now,
|
|
53
|
+
sessionId, title, createdAt: now, updatedAt: now,
|
|
52
54
|
}
|
|
53
55
|
this.userSessionIndex.get(userId)?.add(metadata);
|
|
54
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainetwork/adk-provider-memory-inmemory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"author": "AI Network (https://ainetwork.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "e0c0ad6b5d60c854c2df08b1eb6836370d1dac06"
|
|
34
34
|
}
|