@tuturuuu/ai 0.0.10
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 +76 -0
- package/package.json +106 -0
- package/src/api-key-hash.ts +28 -0
- package/src/calendar/events.ts +34 -0
- package/src/calendar/route.ts +114 -0
- package/src/chat/credit-source.ts +1 -0
- package/src/chat/google/chat-request-schema.ts +150 -0
- package/src/chat/google/default-system-instruction.ts +198 -0
- package/src/chat/google/message-file-processing.ts +212 -0
- package/src/chat/google/mira-step-preparation.ts +221 -0
- package/src/chat/google/new/route.ts +368 -0
- package/src/chat/google/route-auth.ts +81 -0
- package/src/chat/google/route-chat-resolution.ts +98 -0
- package/src/chat/google/route-credits.ts +61 -0
- package/src/chat/google/route-message-preparation.ts +331 -0
- package/src/chat/google/route-mira-runtime.ts +206 -0
- package/src/chat/google/route.ts +632 -0
- package/src/chat/google/stream-finish-persistence.ts +722 -0
- package/src/chat/google/summary/route.ts +153 -0
- package/src/chat/mira-render-ui-policy.ts +540 -0
- package/src/chat/mira-system-instruction.ts +484 -0
- package/src/chat-sdk/adapters.ts +389 -0
- package/src/chat-sdk/registry.ts +197 -0
- package/src/chat-sdk.ts +33 -0
- package/src/core.ts +3 -0
- package/src/credits/cap-output-tokens.ts +90 -0
- package/src/credits/check-credits.ts +232 -0
- package/src/credits/constants.ts +30 -0
- package/src/credits/index.ts +46 -0
- package/src/credits/model-mapping.ts +92 -0
- package/src/credits/reservations.ts +514 -0
- package/src/credits/resolve-plan-model.ts +219 -0
- package/src/credits/sync-gateway-models.ts +351 -0
- package/src/credits/types.ts +109 -0
- package/src/credits/use-ai-credits.ts +3 -0
- package/src/embeddings/metered.ts +283 -0
- package/src/executions/route.ts +137 -0
- package/src/generate/route.ts +411 -0
- package/src/hooks.ts +7 -0
- package/src/meetings/summary/route.ts +7 -0
- package/src/meetings/transcription/route.ts +134 -0
- package/src/memory/client.ts +158 -0
- package/src/memory/config.ts +38 -0
- package/src/memory/index.ts +32 -0
- package/src/memory/ingest.ts +51 -0
- package/src/memory/middleware.ts +35 -0
- package/src/memory/operations.ts +480 -0
- package/src/memory/scope.ts +102 -0
- package/src/memory/settings.ts +121 -0
- package/src/memory/types.ts +101 -0
- package/src/memory/workspace.ts +36 -0
- package/src/memory.ts +1 -0
- package/src/mind/patch.ts +146 -0
- package/src/mind/route.ts +687 -0
- package/src/mind/tools.ts +1500 -0
- package/src/mind/types.ts +20 -0
- package/src/object/core.ts +3 -0
- package/src/object/flashcards/route.ts +140 -0
- package/src/object/quizzes/explanation/route.ts +145 -0
- package/src/object/quizzes/route.ts +142 -0
- package/src/object/types.ts +187 -0
- package/src/object/year-plan/route.ts +196 -0
- package/src/react.ts +1 -0
- package/src/scheduling/algorithm.ts +791 -0
- package/src/scheduling/default.ts +36 -0
- package/src/scheduling/duration-optimizer.ts +689 -0
- package/src/scheduling/index.ts +79 -0
- package/src/scheduling/priority-calculator.ts +187 -0
- package/src/scheduling/recurrence-calculator.ts +621 -0
- package/src/scheduling/templates.ts +892 -0
- package/src/scheduling/types.ts +136 -0
- package/src/scheduling/web-adapter.ts +308 -0
- package/src/scheduling.ts +6 -0
- package/src/supported-actions.ts +1 -0
- package/src/supported-providers.ts +6 -0
- package/src/tools/context-builder.ts +372 -0
- package/src/tools/core.ts +1 -0
- package/src/tools/definitions/calendar.ts +106 -0
- package/src/tools/definitions/finance.ts +197 -0
- package/src/tools/definitions/image.ts +74 -0
- package/src/tools/definitions/memory.ts +83 -0
- package/src/tools/definitions/meta.ts +154 -0
- package/src/tools/definitions/render-ui.ts +81 -0
- package/src/tools/definitions/tasks.ts +343 -0
- package/src/tools/definitions/time-tracking.ts +381 -0
- package/src/tools/definitions/workspace-context.ts +45 -0
- package/src/tools/definitions/workspace-user-chat.ts +111 -0
- package/src/tools/executors/calendar.ts +371 -0
- package/src/tools/executors/chat.ts +15 -0
- package/src/tools/executors/finance.ts +638 -0
- package/src/tools/executors/helpers/encryption.ts +107 -0
- package/src/tools/executors/image.ts +247 -0
- package/src/tools/executors/markitdown.ts +684 -0
- package/src/tools/executors/memory.ts +277 -0
- package/src/tools/executors/parallel-checks.ts +176 -0
- package/src/tools/executors/qr.ts +170 -0
- package/src/tools/executors/scope-helpers.ts +192 -0
- package/src/tools/executors/search.ts +149 -0
- package/src/tools/executors/settings.ts +40 -0
- package/src/tools/executors/tasks.ts +1087 -0
- package/src/tools/executors/theme.ts +23 -0
- package/src/tools/executors/timer/timer-categories-executor.ts +110 -0
- package/src/tools/executors/timer/timer-category-mutations.ts +240 -0
- package/src/tools/executors/timer/timer-goal-mutations.ts +323 -0
- package/src/tools/executors/timer/timer-goals-executor.ts +272 -0
- package/src/tools/executors/timer/timer-helpers.ts +372 -0
- package/src/tools/executors/timer/timer-mutation-schemas.ts +160 -0
- package/src/tools/executors/timer/timer-mutation-types.ts +212 -0
- package/src/tools/executors/timer/timer-mutations.ts +19 -0
- package/src/tools/executors/timer/timer-queries.ts +18 -0
- package/src/tools/executors/timer/timer-session-lifecycle.ts +299 -0
- package/src/tools/executors/timer/timer-session-mutations.ts +10 -0
- package/src/tools/executors/timer/timer-session-queries.ts +153 -0
- package/src/tools/executors/timer/timer-session-updates.ts +200 -0
- package/src/tools/executors/timer/timer-sessions-executor.ts +91 -0
- package/src/tools/executors/timer/timer-stats-executor.ts +157 -0
- package/src/tools/executors/timer.ts +22 -0
- package/src/tools/executors/user.ts +60 -0
- package/src/tools/executors/workspace.ts +135 -0
- package/src/tools/json-render-catalog.ts +875 -0
- package/src/tools/mira-tool-definitions.ts +55 -0
- package/src/tools/mira-tool-dispatcher.ts +265 -0
- package/src/tools/mira-tool-metadata.ts +164 -0
- package/src/tools/mira-tool-names.ts +95 -0
- package/src/tools/mira-tool-render-ui.ts +54 -0
- package/src/tools/mira-tool-types.ts +17 -0
- package/src/tools/mira-tools.ts +167 -0
- package/src/tools/normalize-render-ui-input.ts +321 -0
- package/src/tools/workspace-context.ts +233 -0
- package/src/types.ts +38 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { Tables } from '@tuturuuu/types';
|
|
2
|
+
import type { MiraToolContext } from '../mira-tools';
|
|
3
|
+
import {
|
|
4
|
+
getWorkspaceContextWorkspaceId,
|
|
5
|
+
listAccessibleWorkspaceSummaries,
|
|
6
|
+
resolveWorkspaceContextState,
|
|
7
|
+
} from '../workspace-context';
|
|
8
|
+
|
|
9
|
+
interface WorkspaceMemberWithUsers
|
|
10
|
+
extends Pick<Tables<'workspace_members'>, 'user_id' | 'created_at'> {
|
|
11
|
+
users: Tables<'users'>[] | Tables<'users'> | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function executeListWorkspaceMembers(
|
|
15
|
+
_args: Record<string, unknown>,
|
|
16
|
+
ctx: MiraToolContext
|
|
17
|
+
) {
|
|
18
|
+
const workspaceId = getWorkspaceContextWorkspaceId(ctx);
|
|
19
|
+
const currentWorkspaceContext =
|
|
20
|
+
ctx.workspaceContext ??
|
|
21
|
+
(await resolveWorkspaceContextState({
|
|
22
|
+
supabase: ctx.supabase,
|
|
23
|
+
userId: ctx.userId,
|
|
24
|
+
requestedWorkspaceContextId: workspaceId,
|
|
25
|
+
fallbackWorkspaceId: ctx.wsId,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const { data, error } = await ctx.supabase
|
|
29
|
+
.from('workspace_members')
|
|
30
|
+
.select(
|
|
31
|
+
`
|
|
32
|
+
user_id,
|
|
33
|
+
created_at,
|
|
34
|
+
users:user_id (
|
|
35
|
+
display_name,
|
|
36
|
+
avatar_url
|
|
37
|
+
)
|
|
38
|
+
`
|
|
39
|
+
)
|
|
40
|
+
.eq('ws_id', workspaceId)
|
|
41
|
+
.order('created_at', { ascending: true });
|
|
42
|
+
|
|
43
|
+
if (error) return { error: error.message };
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
currentWorkspaceContext,
|
|
47
|
+
count: data?.length ?? 0,
|
|
48
|
+
note: `These members are from the current workspace context: ${currentWorkspaceContext.name}.`,
|
|
49
|
+
members: ((data ?? []) as WorkspaceMemberWithUsers[]).map((m) => {
|
|
50
|
+
const user = Array.isArray(m.users) ? (m.users[0] ?? null) : m.users;
|
|
51
|
+
return {
|
|
52
|
+
userId: m.user_id,
|
|
53
|
+
role: null,
|
|
54
|
+
displayName: user?.display_name ?? null,
|
|
55
|
+
joinedAt: m.created_at,
|
|
56
|
+
};
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function executeListAccessibleWorkspaces(
|
|
62
|
+
_args: Record<string, unknown>,
|
|
63
|
+
ctx: MiraToolContext
|
|
64
|
+
) {
|
|
65
|
+
try {
|
|
66
|
+
const workspaces = await listAccessibleWorkspaceSummaries(
|
|
67
|
+
ctx.supabase,
|
|
68
|
+
ctx.userId
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
count: workspaces.length,
|
|
73
|
+
currentWorkspaceContext: ctx.workspaceContext,
|
|
74
|
+
workspaces,
|
|
75
|
+
};
|
|
76
|
+
} catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
error:
|
|
79
|
+
error instanceof Error
|
|
80
|
+
? error.message
|
|
81
|
+
: 'Failed to list accessible workspaces.',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function executeGetWorkspaceContext(
|
|
87
|
+
_args: Record<string, unknown>,
|
|
88
|
+
ctx: MiraToolContext
|
|
89
|
+
) {
|
|
90
|
+
return {
|
|
91
|
+
currentWorkspaceContext: ctx.workspaceContext,
|
|
92
|
+
note: 'Use this workspace for task, calendar, and finance queries unless the user explicitly specifies another workspace.',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function executeSetWorkspaceContext(
|
|
97
|
+
args: Record<string, unknown>,
|
|
98
|
+
ctx: MiraToolContext
|
|
99
|
+
) {
|
|
100
|
+
const workspaceId =
|
|
101
|
+
typeof args.workspaceId === 'string'
|
|
102
|
+
? args.workspaceId
|
|
103
|
+
: typeof args.workspaceContextId === 'string'
|
|
104
|
+
? args.workspaceContextId
|
|
105
|
+
: '';
|
|
106
|
+
if (!workspaceId.trim()) {
|
|
107
|
+
return { error: 'workspaceId is required.' };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const resolvedContext = await resolveWorkspaceContextState({
|
|
112
|
+
supabase: ctx.supabase,
|
|
113
|
+
userId: ctx.userId,
|
|
114
|
+
requestedWorkspaceContextId: workspaceId,
|
|
115
|
+
fallbackWorkspaceId: getWorkspaceContextWorkspaceId(ctx),
|
|
116
|
+
strict: true,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
ctx.workspaceContext = resolvedContext;
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
success: true,
|
|
123
|
+
message: `Workspace context switched to ${resolvedContext.name}.`,
|
|
124
|
+
workspaceContextId: resolvedContext.workspaceContextId,
|
|
125
|
+
currentWorkspaceContext: resolvedContext,
|
|
126
|
+
};
|
|
127
|
+
} catch (error) {
|
|
128
|
+
return {
|
|
129
|
+
error:
|
|
130
|
+
error instanceof Error
|
|
131
|
+
? error.message
|
|
132
|
+
: 'Failed to switch workspace context.',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|