@jungjaehoon/mama-os 0.68.1 → 0.69.0
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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/api/help-actions.d.ts +2 -2
- package/dist/api/help-actions.d.ts.map +1 -1
- package/dist/api/help-actions.js +6 -3
- package/dist/api/help-actions.js.map +1 -1
- package/dist/api/stored-source-reader.d.ts +1 -1
- package/dist/api/stored-source-reader.d.ts.map +1 -1
- package/dist/api/stored-source-reader.js +14 -0
- package/dist/api/stored-source-reader.js.map +1 -1
- package/dist/api/viewer-data.d.ts +4 -4
- package/dist/api/viewer-data.d.ts.map +1 -1
- package/dist/api/viewer-data.js +84 -40
- package/dist/api/viewer-data.js.map +1 -1
- package/dist/api/viewer-server.d.ts.map +1 -1
- package/dist/api/viewer-server.js +12 -5
- package/dist/api/viewer-server.js.map +1 -1
- package/dist/runtime/action-surface.d.ts +3 -0
- package/dist/runtime/action-surface.d.ts.map +1 -1
- package/dist/runtime/action-surface.js +35 -6
- package/dist/runtime/action-surface.js.map +1 -1
- package/dist/runtime/owner-runtime.d.ts +3 -1
- package/dist/runtime/owner-runtime.d.ts.map +1 -1
- package/dist/runtime/owner-runtime.js +9 -2
- package/dist/runtime/owner-runtime.js.map +1 -1
- package/dist/runtime/principal-access.d.ts +10 -0
- package/dist/runtime/principal-access.d.ts.map +1 -0
- package/dist/runtime/principal-access.js +61 -0
- package/dist/runtime/principal-access.js.map +1 -0
- package/package.json +2 -2
- package/public/viewer/js/modules/memory-timeline.js +1 -1
- package/public/viewer/src/modules/memory-timeline.ts +1 -1
- package/public/viewer/src/utils/api.ts +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvePrincipalAccess = resolvePrincipalAccess;
|
|
4
|
+
const mama_core_1 = require("@jungjaehoon/mama-core");
|
|
5
|
+
const action_surface_js_1 = require("./action-surface.js");
|
|
6
|
+
/** Registry-backed authority for future member turns; admission is wired separately. */
|
|
7
|
+
function resolvePrincipalAccess(principalId, options) {
|
|
8
|
+
const { adapter, ownerAccess, agentId } = options;
|
|
9
|
+
const principal = adapter
|
|
10
|
+
.prepare('SELECT kind, status FROM principals WHERE principal_id = ?')
|
|
11
|
+
.get(principalId);
|
|
12
|
+
if (!principal)
|
|
13
|
+
throw new Error(`unknown principal: ${principalId}`);
|
|
14
|
+
if (principal.status !== 'active')
|
|
15
|
+
throw new Error(`principal ${principalId} is ${principal.status}`);
|
|
16
|
+
if (principal.kind === 'owner') {
|
|
17
|
+
if (principalId !== ownerAccess.principalId)
|
|
18
|
+
throw new Error(`principal ${principalId} is not the configured owner`);
|
|
19
|
+
return ownerAccess;
|
|
20
|
+
}
|
|
21
|
+
const identities = adapter
|
|
22
|
+
.prepare(`SELECT external_id FROM external_identities
|
|
23
|
+
WHERE principal_id = ? AND connector = 'telegram' AND namespace = 'private'`)
|
|
24
|
+
.all(principalId);
|
|
25
|
+
if (identities.length !== 1)
|
|
26
|
+
throw new Error(`member ${principalId} requires exactly one Telegram private identity`);
|
|
27
|
+
const dmId = identities[0].external_id;
|
|
28
|
+
// Every owner work item is bound to all of the owner's scopes, so a grant on one opens them all.
|
|
29
|
+
const ownerDefaults = new Set(ownerAccess.scopes.map((scope) => `${scope.kind}\0${scope.id}`));
|
|
30
|
+
const readScopes = [];
|
|
31
|
+
const connectors = new Set(['chat']);
|
|
32
|
+
// chat-sources stores gateway channelKey under the transport prefix.
|
|
33
|
+
const channels = { chat: [`telegram:${dmId}`] };
|
|
34
|
+
for (const { scope } of (0, mama_core_1.createPrincipalRepository)(adapter).listActiveGrants(principalId)) {
|
|
35
|
+
if (scope.kind === 'memory') {
|
|
36
|
+
if (ownerDefaults.has(`${scope.scopeKind}\0${scope.scopeId}`))
|
|
37
|
+
throw new Error(`member memory grant overlaps owner default scope: ${scope.scopeKind}:${scope.scopeId}`);
|
|
38
|
+
readScopes.push({ kind: scope.scopeKind, id: scope.scopeId });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
connectors.add(scope.connector);
|
|
42
|
+
const granted = channels[scope.connector] ?? [];
|
|
43
|
+
if (!granted.includes(scope.channelId))
|
|
44
|
+
granted.push(scope.channelId);
|
|
45
|
+
channels[scope.connector] = granted;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const personalScope = { kind: 'user', id: principalId };
|
|
49
|
+
return {
|
|
50
|
+
principalId,
|
|
51
|
+
agentId,
|
|
52
|
+
scopes: [personalScope],
|
|
53
|
+
defaultScopes: [personalScope],
|
|
54
|
+
readScopes,
|
|
55
|
+
connectors: [...connectors],
|
|
56
|
+
channels,
|
|
57
|
+
destinations: [{ kind: 'telegram', id: dmId }],
|
|
58
|
+
actions: action_surface_js_1.MEMBER_ACTIONS,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=principal-access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-access.js","sourceRoot":"","sources":["../../src/runtime/principal-access.ts"],"names":[],"mappings":";;AAaA,wDA0DC;AAvED,sDAAsF;AAItF,2DAAqD;AAQrD,wFAAwF;AACxF,SAAgB,sBAAsB,CACpC,WAAmB,EACnB,OAA+B;IAE/B,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO;SACtB,OAAO,CAAC,4DAA4D,CAAC;SACrE,GAAG,CAAC,WAAW,CAAsD,CAAC;IACzE,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,WAAW,EAAE,CAAC,CAAC;IACrE,IAAI,SAAS,CAAC,MAAM,KAAK,QAAQ;QAC/B,MAAM,IAAI,KAAK,CAAC,aAAa,WAAW,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACrE,I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,CAAC;YACJ,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAChD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACtE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;QACtC,CAAC;IACH,CAAC;IACD,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,MAAe,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;IACjE,OAAO;QACL,WAAW;QACX,OAAO;QACP,MAAM,EAAE,CAAC,aAAa,CAAC;QACvB,aAAa,EAAE,CAAC,aAAa,CAAC;QAC9B,UAAU;QACV,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC;QAC3B,QAAQ;QACR,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QAC9C,OAAO,EAAE,kCAAc;KACxB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jungjaehoon/mama-os",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"description": "MAMA OS - The local work agent behind your messenger.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@slack/web-api": "^7.13.0",
|
|
53
53
|
"@slack/socket-mode": "^2.0.5",
|
|
54
54
|
"discord.js": "^14.25.1",
|
|
55
|
-
"@jungjaehoon/mama-core": "^
|
|
55
|
+
"@jungjaehoon/mama-core": "^8.0.0",
|
|
56
56
|
"better-sqlite3": "^12.8.0",
|
|
57
57
|
"express": "^5.2.1",
|
|
58
58
|
"grammy": "^1.42.0",
|
|
@@ -170,7 +170,7 @@ export class MemoryTimelineModule {
|
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
172
|
list.innerHTML = data.days
|
|
173
|
-
.map((day) => `<section class="mt-day"><h3 class="mt-day-head"><span>${escapeHtml(dayLabel(day.day))}</span><span class="mt-count">${day.total}</span></h3>${day.groups
|
|
173
|
+
.map((day) => `<section class="mt-day"><h3 class="mt-day-head"><span>${escapeHtml(day.day === null ? 'Erased records' : dayLabel(day.day))}</span><span class="mt-count">${day.total}</span></h3>${day.groups
|
|
174
174
|
.map((group) => this.renderGroup(group))
|
|
175
175
|
.join('')}</section>`)
|
|
176
176
|
.join('');
|
|
@@ -196,7 +196,7 @@ export class MemoryTimelineModule {
|
|
|
196
196
|
.map(
|
|
197
197
|
(day) =>
|
|
198
198
|
`<section class="mt-day"><h3 class="mt-day-head"><span>${escapeHtml(
|
|
199
|
-
dayLabel(day.day)
|
|
199
|
+
day.day === null ? 'Erased records' : dayLabel(day.day)
|
|
200
200
|
)}</span><span class="mt-count">${day.total}</span></h3>${day.groups
|
|
201
201
|
.map((group) => this.renderGroup(group))
|
|
202
202
|
.join('')}</section>`
|
|
@@ -92,7 +92,7 @@ export interface MemoryTimelineResponse {
|
|
|
92
92
|
timeZone: string;
|
|
93
93
|
total: number;
|
|
94
94
|
counts: Record<string, number>;
|
|
95
|
-
days: Array<{ day: string; total: number; groups: TimelineGroup[] }>;
|
|
95
|
+
days: Array<{ day: string | null; total: number; groups: TimelineGroup[] }>;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
export interface CheckpointSummary {
|