MCPcopy Create free account
hub / github.com/cortexkit/magic-context / invoke

Function invoke

packages/dashboard/src/lib/platform.ts:32–47  ·  view source on GitHub ↗
(cmd: string, args?: Record<string, unknown>)

Source from the content-addressed store, hash-verified

30}
31
32export async function invoke<T>(cmd: string, args?: Record<string, unknown>): Promise<T> {
33 if (isTauri()) return tauriInvoke<T>(cmd, args);
34 const response = await fetch("/api/invoke", {
35 method: "POST",
36 headers: {
37 "Content-Type": "application/json",
38 ...(token ? { Authorization: `Bearer ${token}` } : {}),
39 },
40 body: JSON.stringify({ cmd, args: args ?? {} }),
41 });
42 const body = await response.json().catch(() => null);
43 if (!response.ok) {
44 throw new Error(body?.error ?? `HTTP ${response.status}`);
45 }
46 return body as T;
47}
48
49export async function ask(message: string, options?: AskOptions): Promise<boolean> {
50 if (isTauri()) return tauriAsk(message, options);

Callers 15

platform.test.tsFile · 0.90
getProjectsFunction · 0.90
getMemoriesFunction · 0.90
getMemoryStatsFunction · 0.90
getPrimersFunction · 0.90
getPrimerCandidatesFunction · 0.90
workspaceSchemaReadyFunction · 0.90
listWorkspacesFunction · 0.90
listWorkspaceSummariesFunction · 0.90
createWorkspaceFunction · 0.90
renameWorkspaceFunction · 0.90

Calls 1

isTauriFunction · 0.85

Tested by

no test coverage detected