@voicethere/agent 0.36.1 → 0.37.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/README.md +11 -11
- package/dist/llm/mcp/mcp-tool-source.d.ts +10 -0
- package/dist/llm/mcp/mcp-tool-source.d.ts.map +1 -1
- package/dist/llm/mcp/mcp-tool-source.js +50 -2
- package/dist/llm/mcp/mcp-tool-source.js.map +1 -1
- package/dist/templates/flow-agent/agent.js +42 -3
- package/dist/templates/game-sync/agent.js +256 -52
- package/dist/templates/llm-agent/agent.js +42 -3
- package/dist/templates/llm-board/agent.js +42 -3
- package/dist/templates/llm-docs-rag/agent.js +42 -3
- package/dist/templates/llm-language-switch/agent.js +42 -3
- package/dist/templates/llm-language-tutor/agent.js +42 -3
- package/dist/templates/llm-mcp-service/agent.js +42 -3
- package/dist/templates/llm-store-support/agent.js +42 -3
- package/dist/templates/llm-support-sticky-user/agent.js +42 -3
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +8 -3
- package/dist/templates/registry.js.map +1 -1
- package/dist/templates/world-sync/agent.js +22 -1
- package/dist/templates/world-sync-binary/agent.js +22 -1
- package/eject/llm/loop.ts +1 -1
- package/package.json +30 -1
- package/templates/README.md +11 -11
- package/templates/game-sync/README.md +13 -4
- package/templates/game-sync/agent.ts +175 -60
- package/templates/game-sync/protocol.ts +3 -0
- package/templates/game-sync/quantize.ts +53 -0
- package/templates/game-sync/redis.ts +51 -1
- package/templates/game-sync/sim.ts +6 -0
- package/templates/game-sync/world-layout.ts +191 -0
- package/templates/redis-sync/README.md +7 -5
- package/templates/redis-sync/agent.ts +77 -65
- package/templates/redis-sync/quantize.ts +53 -0
- package/templates/redis-sync/quantized-frames.vectors.json +249 -0
- package/templates/redis-sync/world-layout.ts +278 -116
- package/templates/world-sync/README.md +1 -1
- package/templates/world-sync/agent.ts +39 -4
- package/templates/world-sync-binary/README.md +1 -1
- package/templates/world-sync-binary/agent.ts +29 -2
|
@@ -32639,6 +32639,7 @@ function toolsHash(all) {
|
|
|
32639
32639
|
var DEFAULT_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
32640
32640
|
var MAX_LIST_PAGES = 10;
|
|
32641
32641
|
var REQUEST_TIMEOUT_CODE = -32001;
|
|
32642
|
+
var CONNECTION_LOST = Symbol("connection-lost");
|
|
32642
32643
|
function readPackageVersion() {
|
|
32643
32644
|
try {
|
|
32644
32645
|
const require2 = createRequire(import.meta.url);
|
|
@@ -32653,12 +32654,23 @@ function errorFields(err) {
|
|
|
32653
32654
|
if (err instanceof Error) {
|
|
32654
32655
|
const code = err.code;
|
|
32655
32656
|
const name = err.constructor.name || err.name;
|
|
32656
|
-
|
|
32657
|
+
const out = {
|
|
32657
32658
|
error: code !== void 0 ? `${name} ${String(code)}` : name
|
|
32658
32659
|
};
|
|
32660
|
+
const cause = err.cause;
|
|
32661
|
+
if (cause instanceof Error) {
|
|
32662
|
+
out.cause = cause.constructor.name || cause.name;
|
|
32663
|
+
const causeCode = cause.code;
|
|
32664
|
+
if (causeCode !== void 0)
|
|
32665
|
+
out.causeCode = String(causeCode);
|
|
32666
|
+
}
|
|
32667
|
+
return out;
|
|
32659
32668
|
}
|
|
32660
32669
|
return { error: typeof err };
|
|
32661
32670
|
}
|
|
32671
|
+
function retryableAfterReconnect(tool) {
|
|
32672
|
+
return tool?.annotations?.readOnlyHint === true || tool?.annotations?.idempotentHint === true;
|
|
32673
|
+
}
|
|
32662
32674
|
function urlOrigin(url2) {
|
|
32663
32675
|
try {
|
|
32664
32676
|
return new URL(url2).origin;
|
|
@@ -32760,10 +32772,31 @@ var McpToolSource = class {
|
|
|
32760
32772
|
return this.cached.map((t) => ({ ...t }));
|
|
32761
32773
|
}
|
|
32762
32774
|
async callTool(name, args, opts) {
|
|
32775
|
+
const deadline = Date.now() + opts.timeoutMs;
|
|
32776
|
+
const tool = this.cached.find((t) => t.name === name);
|
|
32777
|
+
const first = await this.callOnce(name, args, opts.signal, opts.timeoutMs);
|
|
32778
|
+
if (first !== CONNECTION_LOST)
|
|
32779
|
+
return first;
|
|
32780
|
+
const unavailable = {
|
|
32781
|
+
isError: true,
|
|
32782
|
+
content: `tool ${name} failed: unavailable`
|
|
32783
|
+
};
|
|
32784
|
+
if (!retryableAfterReconnect(tool) || opts.signal?.aborted)
|
|
32785
|
+
return unavailable;
|
|
32786
|
+
const reconnected = await this.ready(deadline - Date.now());
|
|
32787
|
+
const remaining = deadline - Date.now();
|
|
32788
|
+
if (!reconnected || remaining <= 0 || opts.signal?.aborted)
|
|
32789
|
+
return unavailable;
|
|
32790
|
+
const second = await this.callOnce(name, args, opts.signal, remaining);
|
|
32791
|
+
return second === CONNECTION_LOST ? unavailable : second;
|
|
32792
|
+
}
|
|
32793
|
+
/** One call on the current connection; CONNECTION_LOST when the transport failed. */
|
|
32794
|
+
async callOnce(name, args, signal, timeoutMs) {
|
|
32763
32795
|
const client = this.client;
|
|
32764
32796
|
if (this.state !== "ready" || !client || !this.cached.some((t) => t.name === name)) {
|
|
32765
32797
|
return { isError: true, content: `tool ${name} is not available` };
|
|
32766
32798
|
}
|
|
32799
|
+
const opts = { signal, timeoutMs };
|
|
32767
32800
|
try {
|
|
32768
32801
|
const result = await client.callTool({ name, arguments: args ?? {} }, void 0, { signal: opts.signal, timeout: opts.timeoutMs });
|
|
32769
32802
|
return mapToolResult(result);
|
|
@@ -32779,7 +32812,7 @@ var McpToolSource = class {
|
|
|
32779
32812
|
return { isError: true, content: `tool ${name} failed: unavailable` };
|
|
32780
32813
|
}
|
|
32781
32814
|
this.connectionLost(client, err);
|
|
32782
|
-
return
|
|
32815
|
+
return CONNECTION_LOST;
|
|
32783
32816
|
}
|
|
32784
32817
|
}
|
|
32785
32818
|
async close() {
|
|
@@ -32885,7 +32918,13 @@ var McpToolSource = class {
|
|
|
32885
32918
|
out.push({
|
|
32886
32919
|
name: t.name,
|
|
32887
32920
|
description: t.description ?? "",
|
|
32888
|
-
inputSchema: t.inputSchema
|
|
32921
|
+
inputSchema: t.inputSchema,
|
|
32922
|
+
...t.annotations ? {
|
|
32923
|
+
annotations: {
|
|
32924
|
+
readOnlyHint: t.annotations.readOnlyHint,
|
|
32925
|
+
idempotentHint: t.annotations.idempotentHint
|
|
32926
|
+
}
|
|
32927
|
+
} : {}
|
|
32889
32928
|
});
|
|
32890
32929
|
}
|
|
32891
32930
|
cursor = res.nextCursor;
|
|
@@ -32643,6 +32643,7 @@ function toolsHash(all) {
|
|
|
32643
32643
|
var DEFAULT_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
32644
32644
|
var MAX_LIST_PAGES = 10;
|
|
32645
32645
|
var REQUEST_TIMEOUT_CODE = -32001;
|
|
32646
|
+
var CONNECTION_LOST = Symbol("connection-lost");
|
|
32646
32647
|
function readPackageVersion() {
|
|
32647
32648
|
try {
|
|
32648
32649
|
const require2 = createRequire(import.meta.url);
|
|
@@ -32657,12 +32658,23 @@ function errorFields(err) {
|
|
|
32657
32658
|
if (err instanceof Error) {
|
|
32658
32659
|
const code = err.code;
|
|
32659
32660
|
const name = err.constructor.name || err.name;
|
|
32660
|
-
|
|
32661
|
+
const out = {
|
|
32661
32662
|
error: code !== void 0 ? `${name} ${String(code)}` : name
|
|
32662
32663
|
};
|
|
32664
|
+
const cause = err.cause;
|
|
32665
|
+
if (cause instanceof Error) {
|
|
32666
|
+
out.cause = cause.constructor.name || cause.name;
|
|
32667
|
+
const causeCode = cause.code;
|
|
32668
|
+
if (causeCode !== void 0)
|
|
32669
|
+
out.causeCode = String(causeCode);
|
|
32670
|
+
}
|
|
32671
|
+
return out;
|
|
32663
32672
|
}
|
|
32664
32673
|
return { error: typeof err };
|
|
32665
32674
|
}
|
|
32675
|
+
function retryableAfterReconnect(tool) {
|
|
32676
|
+
return tool?.annotations?.readOnlyHint === true || tool?.annotations?.idempotentHint === true;
|
|
32677
|
+
}
|
|
32666
32678
|
function urlOrigin(url2) {
|
|
32667
32679
|
try {
|
|
32668
32680
|
return new URL(url2).origin;
|
|
@@ -32764,10 +32776,31 @@ var McpToolSource = class {
|
|
|
32764
32776
|
return this.cached.map((t) => ({ ...t }));
|
|
32765
32777
|
}
|
|
32766
32778
|
async callTool(name, args, opts) {
|
|
32779
|
+
const deadline = Date.now() + opts.timeoutMs;
|
|
32780
|
+
const tool = this.cached.find((t) => t.name === name);
|
|
32781
|
+
const first = await this.callOnce(name, args, opts.signal, opts.timeoutMs);
|
|
32782
|
+
if (first !== CONNECTION_LOST)
|
|
32783
|
+
return first;
|
|
32784
|
+
const unavailable = {
|
|
32785
|
+
isError: true,
|
|
32786
|
+
content: `tool ${name} failed: unavailable`
|
|
32787
|
+
};
|
|
32788
|
+
if (!retryableAfterReconnect(tool) || opts.signal?.aborted)
|
|
32789
|
+
return unavailable;
|
|
32790
|
+
const reconnected = await this.ready(deadline - Date.now());
|
|
32791
|
+
const remaining = deadline - Date.now();
|
|
32792
|
+
if (!reconnected || remaining <= 0 || opts.signal?.aborted)
|
|
32793
|
+
return unavailable;
|
|
32794
|
+
const second = await this.callOnce(name, args, opts.signal, remaining);
|
|
32795
|
+
return second === CONNECTION_LOST ? unavailable : second;
|
|
32796
|
+
}
|
|
32797
|
+
/** One call on the current connection; CONNECTION_LOST when the transport failed. */
|
|
32798
|
+
async callOnce(name, args, signal, timeoutMs) {
|
|
32767
32799
|
const client = this.client;
|
|
32768
32800
|
if (this.state !== "ready" || !client || !this.cached.some((t) => t.name === name)) {
|
|
32769
32801
|
return { isError: true, content: `tool ${name} is not available` };
|
|
32770
32802
|
}
|
|
32803
|
+
const opts = { signal, timeoutMs };
|
|
32771
32804
|
try {
|
|
32772
32805
|
const result = await client.callTool({ name, arguments: args ?? {} }, void 0, { signal: opts.signal, timeout: opts.timeoutMs });
|
|
32773
32806
|
return mapToolResult(result);
|
|
@@ -32783,7 +32816,7 @@ var McpToolSource = class {
|
|
|
32783
32816
|
return { isError: true, content: `tool ${name} failed: unavailable` };
|
|
32784
32817
|
}
|
|
32785
32818
|
this.connectionLost(client, err);
|
|
32786
|
-
return
|
|
32819
|
+
return CONNECTION_LOST;
|
|
32787
32820
|
}
|
|
32788
32821
|
}
|
|
32789
32822
|
async close() {
|
|
@@ -32889,7 +32922,13 @@ var McpToolSource = class {
|
|
|
32889
32922
|
out.push({
|
|
32890
32923
|
name: t.name,
|
|
32891
32924
|
description: t.description ?? "",
|
|
32892
|
-
inputSchema: t.inputSchema
|
|
32925
|
+
inputSchema: t.inputSchema,
|
|
32926
|
+
...t.annotations ? {
|
|
32927
|
+
annotations: {
|
|
32928
|
+
readOnlyHint: t.annotations.readOnlyHint,
|
|
32929
|
+
idempotentHint: t.annotations.idempotentHint
|
|
32930
|
+
}
|
|
32931
|
+
} : {}
|
|
32893
32932
|
});
|
|
32894
32933
|
}
|
|
32895
32934
|
cursor = res.nextCursor;
|
|
@@ -32639,6 +32639,7 @@ function toolsHash(all) {
|
|
|
32639
32639
|
var DEFAULT_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
32640
32640
|
var MAX_LIST_PAGES = 10;
|
|
32641
32641
|
var REQUEST_TIMEOUT_CODE = -32001;
|
|
32642
|
+
var CONNECTION_LOST = Symbol("connection-lost");
|
|
32642
32643
|
function readPackageVersion() {
|
|
32643
32644
|
try {
|
|
32644
32645
|
const require2 = createRequire(import.meta.url);
|
|
@@ -32653,12 +32654,23 @@ function errorFields(err) {
|
|
|
32653
32654
|
if (err instanceof Error) {
|
|
32654
32655
|
const code = err.code;
|
|
32655
32656
|
const name = err.constructor.name || err.name;
|
|
32656
|
-
|
|
32657
|
+
const out = {
|
|
32657
32658
|
error: code !== void 0 ? `${name} ${String(code)}` : name
|
|
32658
32659
|
};
|
|
32660
|
+
const cause = err.cause;
|
|
32661
|
+
if (cause instanceof Error) {
|
|
32662
|
+
out.cause = cause.constructor.name || cause.name;
|
|
32663
|
+
const causeCode = cause.code;
|
|
32664
|
+
if (causeCode !== void 0)
|
|
32665
|
+
out.causeCode = String(causeCode);
|
|
32666
|
+
}
|
|
32667
|
+
return out;
|
|
32659
32668
|
}
|
|
32660
32669
|
return { error: typeof err };
|
|
32661
32670
|
}
|
|
32671
|
+
function retryableAfterReconnect(tool) {
|
|
32672
|
+
return tool?.annotations?.readOnlyHint === true || tool?.annotations?.idempotentHint === true;
|
|
32673
|
+
}
|
|
32662
32674
|
function urlOrigin(url2) {
|
|
32663
32675
|
try {
|
|
32664
32676
|
return new URL(url2).origin;
|
|
@@ -32760,10 +32772,31 @@ var McpToolSource = class {
|
|
|
32760
32772
|
return this.cached.map((t) => ({ ...t }));
|
|
32761
32773
|
}
|
|
32762
32774
|
async callTool(name, args, opts) {
|
|
32775
|
+
const deadline = Date.now() + opts.timeoutMs;
|
|
32776
|
+
const tool = this.cached.find((t) => t.name === name);
|
|
32777
|
+
const first = await this.callOnce(name, args, opts.signal, opts.timeoutMs);
|
|
32778
|
+
if (first !== CONNECTION_LOST)
|
|
32779
|
+
return first;
|
|
32780
|
+
const unavailable = {
|
|
32781
|
+
isError: true,
|
|
32782
|
+
content: `tool ${name} failed: unavailable`
|
|
32783
|
+
};
|
|
32784
|
+
if (!retryableAfterReconnect(tool) || opts.signal?.aborted)
|
|
32785
|
+
return unavailable;
|
|
32786
|
+
const reconnected = await this.ready(deadline - Date.now());
|
|
32787
|
+
const remaining = deadline - Date.now();
|
|
32788
|
+
if (!reconnected || remaining <= 0 || opts.signal?.aborted)
|
|
32789
|
+
return unavailable;
|
|
32790
|
+
const second = await this.callOnce(name, args, opts.signal, remaining);
|
|
32791
|
+
return second === CONNECTION_LOST ? unavailable : second;
|
|
32792
|
+
}
|
|
32793
|
+
/** One call on the current connection; CONNECTION_LOST when the transport failed. */
|
|
32794
|
+
async callOnce(name, args, signal, timeoutMs) {
|
|
32763
32795
|
const client = this.client;
|
|
32764
32796
|
if (this.state !== "ready" || !client || !this.cached.some((t) => t.name === name)) {
|
|
32765
32797
|
return { isError: true, content: `tool ${name} is not available` };
|
|
32766
32798
|
}
|
|
32799
|
+
const opts = { signal, timeoutMs };
|
|
32767
32800
|
try {
|
|
32768
32801
|
const result = await client.callTool({ name, arguments: args ?? {} }, void 0, { signal: opts.signal, timeout: opts.timeoutMs });
|
|
32769
32802
|
return mapToolResult(result);
|
|
@@ -32779,7 +32812,7 @@ var McpToolSource = class {
|
|
|
32779
32812
|
return { isError: true, content: `tool ${name} failed: unavailable` };
|
|
32780
32813
|
}
|
|
32781
32814
|
this.connectionLost(client, err);
|
|
32782
|
-
return
|
|
32815
|
+
return CONNECTION_LOST;
|
|
32783
32816
|
}
|
|
32784
32817
|
}
|
|
32785
32818
|
async close() {
|
|
@@ -32885,7 +32918,13 @@ var McpToolSource = class {
|
|
|
32885
32918
|
out.push({
|
|
32886
32919
|
name: t.name,
|
|
32887
32920
|
description: t.description ?? "",
|
|
32888
|
-
inputSchema: t.inputSchema
|
|
32921
|
+
inputSchema: t.inputSchema,
|
|
32922
|
+
...t.annotations ? {
|
|
32923
|
+
annotations: {
|
|
32924
|
+
readOnlyHint: t.annotations.readOnlyHint,
|
|
32925
|
+
idempotentHint: t.annotations.idempotentHint
|
|
32926
|
+
}
|
|
32927
|
+
} : {}
|
|
32889
32928
|
});
|
|
32890
32929
|
}
|
|
32891
32930
|
cursor = res.nextCursor;
|
|
@@ -32639,6 +32639,7 @@ function toolsHash(all) {
|
|
|
32639
32639
|
var DEFAULT_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
32640
32640
|
var MAX_LIST_PAGES = 10;
|
|
32641
32641
|
var REQUEST_TIMEOUT_CODE = -32001;
|
|
32642
|
+
var CONNECTION_LOST = Symbol("connection-lost");
|
|
32642
32643
|
function readPackageVersion() {
|
|
32643
32644
|
try {
|
|
32644
32645
|
const require2 = createRequire(import.meta.url);
|
|
@@ -32653,12 +32654,23 @@ function errorFields(err) {
|
|
|
32653
32654
|
if (err instanceof Error) {
|
|
32654
32655
|
const code = err.code;
|
|
32655
32656
|
const name = err.constructor.name || err.name;
|
|
32656
|
-
|
|
32657
|
+
const out = {
|
|
32657
32658
|
error: code !== void 0 ? `${name} ${String(code)}` : name
|
|
32658
32659
|
};
|
|
32660
|
+
const cause = err.cause;
|
|
32661
|
+
if (cause instanceof Error) {
|
|
32662
|
+
out.cause = cause.constructor.name || cause.name;
|
|
32663
|
+
const causeCode = cause.code;
|
|
32664
|
+
if (causeCode !== void 0)
|
|
32665
|
+
out.causeCode = String(causeCode);
|
|
32666
|
+
}
|
|
32667
|
+
return out;
|
|
32659
32668
|
}
|
|
32660
32669
|
return { error: typeof err };
|
|
32661
32670
|
}
|
|
32671
|
+
function retryableAfterReconnect(tool) {
|
|
32672
|
+
return tool?.annotations?.readOnlyHint === true || tool?.annotations?.idempotentHint === true;
|
|
32673
|
+
}
|
|
32662
32674
|
function urlOrigin(url2) {
|
|
32663
32675
|
try {
|
|
32664
32676
|
return new URL(url2).origin;
|
|
@@ -32760,10 +32772,31 @@ var McpToolSource = class {
|
|
|
32760
32772
|
return this.cached.map((t) => ({ ...t }));
|
|
32761
32773
|
}
|
|
32762
32774
|
async callTool(name, args, opts) {
|
|
32775
|
+
const deadline = Date.now() + opts.timeoutMs;
|
|
32776
|
+
const tool = this.cached.find((t) => t.name === name);
|
|
32777
|
+
const first = await this.callOnce(name, args, opts.signal, opts.timeoutMs);
|
|
32778
|
+
if (first !== CONNECTION_LOST)
|
|
32779
|
+
return first;
|
|
32780
|
+
const unavailable = {
|
|
32781
|
+
isError: true,
|
|
32782
|
+
content: `tool ${name} failed: unavailable`
|
|
32783
|
+
};
|
|
32784
|
+
if (!retryableAfterReconnect(tool) || opts.signal?.aborted)
|
|
32785
|
+
return unavailable;
|
|
32786
|
+
const reconnected = await this.ready(deadline - Date.now());
|
|
32787
|
+
const remaining = deadline - Date.now();
|
|
32788
|
+
if (!reconnected || remaining <= 0 || opts.signal?.aborted)
|
|
32789
|
+
return unavailable;
|
|
32790
|
+
const second = await this.callOnce(name, args, opts.signal, remaining);
|
|
32791
|
+
return second === CONNECTION_LOST ? unavailable : second;
|
|
32792
|
+
}
|
|
32793
|
+
/** One call on the current connection; CONNECTION_LOST when the transport failed. */
|
|
32794
|
+
async callOnce(name, args, signal, timeoutMs) {
|
|
32763
32795
|
const client = this.client;
|
|
32764
32796
|
if (this.state !== "ready" || !client || !this.cached.some((t) => t.name === name)) {
|
|
32765
32797
|
return { isError: true, content: `tool ${name} is not available` };
|
|
32766
32798
|
}
|
|
32799
|
+
const opts = { signal, timeoutMs };
|
|
32767
32800
|
try {
|
|
32768
32801
|
const result = await client.callTool({ name, arguments: args ?? {} }, void 0, { signal: opts.signal, timeout: opts.timeoutMs });
|
|
32769
32802
|
return mapToolResult(result);
|
|
@@ -32779,7 +32812,7 @@ var McpToolSource = class {
|
|
|
32779
32812
|
return { isError: true, content: `tool ${name} failed: unavailable` };
|
|
32780
32813
|
}
|
|
32781
32814
|
this.connectionLost(client, err);
|
|
32782
|
-
return
|
|
32815
|
+
return CONNECTION_LOST;
|
|
32783
32816
|
}
|
|
32784
32817
|
}
|
|
32785
32818
|
async close() {
|
|
@@ -32885,7 +32918,13 @@ var McpToolSource = class {
|
|
|
32885
32918
|
out.push({
|
|
32886
32919
|
name: t.name,
|
|
32887
32920
|
description: t.description ?? "",
|
|
32888
|
-
inputSchema: t.inputSchema
|
|
32921
|
+
inputSchema: t.inputSchema,
|
|
32922
|
+
...t.annotations ? {
|
|
32923
|
+
annotations: {
|
|
32924
|
+
readOnlyHint: t.annotations.readOnlyHint,
|
|
32925
|
+
idempotentHint: t.annotations.idempotentHint
|
|
32926
|
+
}
|
|
32927
|
+
} : {}
|
|
32889
32928
|
});
|
|
32890
32929
|
}
|
|
32891
32930
|
cursor = res.nextCursor;
|
|
@@ -32639,6 +32639,7 @@ function toolsHash(all) {
|
|
|
32639
32639
|
var DEFAULT_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
32640
32640
|
var MAX_LIST_PAGES = 10;
|
|
32641
32641
|
var REQUEST_TIMEOUT_CODE = -32001;
|
|
32642
|
+
var CONNECTION_LOST = Symbol("connection-lost");
|
|
32642
32643
|
function readPackageVersion() {
|
|
32643
32644
|
try {
|
|
32644
32645
|
const require2 = createRequire(import.meta.url);
|
|
@@ -32653,12 +32654,23 @@ function errorFields(err) {
|
|
|
32653
32654
|
if (err instanceof Error) {
|
|
32654
32655
|
const code = err.code;
|
|
32655
32656
|
const name = err.constructor.name || err.name;
|
|
32656
|
-
|
|
32657
|
+
const out = {
|
|
32657
32658
|
error: code !== void 0 ? `${name} ${String(code)}` : name
|
|
32658
32659
|
};
|
|
32660
|
+
const cause = err.cause;
|
|
32661
|
+
if (cause instanceof Error) {
|
|
32662
|
+
out.cause = cause.constructor.name || cause.name;
|
|
32663
|
+
const causeCode = cause.code;
|
|
32664
|
+
if (causeCode !== void 0)
|
|
32665
|
+
out.causeCode = String(causeCode);
|
|
32666
|
+
}
|
|
32667
|
+
return out;
|
|
32659
32668
|
}
|
|
32660
32669
|
return { error: typeof err };
|
|
32661
32670
|
}
|
|
32671
|
+
function retryableAfterReconnect(tool) {
|
|
32672
|
+
return tool?.annotations?.readOnlyHint === true || tool?.annotations?.idempotentHint === true;
|
|
32673
|
+
}
|
|
32662
32674
|
function urlOrigin(url2) {
|
|
32663
32675
|
try {
|
|
32664
32676
|
return new URL(url2).origin;
|
|
@@ -32760,10 +32772,31 @@ var McpToolSource = class {
|
|
|
32760
32772
|
return this.cached.map((t) => ({ ...t }));
|
|
32761
32773
|
}
|
|
32762
32774
|
async callTool(name, args, opts) {
|
|
32775
|
+
const deadline = Date.now() + opts.timeoutMs;
|
|
32776
|
+
const tool = this.cached.find((t) => t.name === name);
|
|
32777
|
+
const first = await this.callOnce(name, args, opts.signal, opts.timeoutMs);
|
|
32778
|
+
if (first !== CONNECTION_LOST)
|
|
32779
|
+
return first;
|
|
32780
|
+
const unavailable = {
|
|
32781
|
+
isError: true,
|
|
32782
|
+
content: `tool ${name} failed: unavailable`
|
|
32783
|
+
};
|
|
32784
|
+
if (!retryableAfterReconnect(tool) || opts.signal?.aborted)
|
|
32785
|
+
return unavailable;
|
|
32786
|
+
const reconnected = await this.ready(deadline - Date.now());
|
|
32787
|
+
const remaining = deadline - Date.now();
|
|
32788
|
+
if (!reconnected || remaining <= 0 || opts.signal?.aborted)
|
|
32789
|
+
return unavailable;
|
|
32790
|
+
const second = await this.callOnce(name, args, opts.signal, remaining);
|
|
32791
|
+
return second === CONNECTION_LOST ? unavailable : second;
|
|
32792
|
+
}
|
|
32793
|
+
/** One call on the current connection; CONNECTION_LOST when the transport failed. */
|
|
32794
|
+
async callOnce(name, args, signal, timeoutMs) {
|
|
32763
32795
|
const client = this.client;
|
|
32764
32796
|
if (this.state !== "ready" || !client || !this.cached.some((t) => t.name === name)) {
|
|
32765
32797
|
return { isError: true, content: `tool ${name} is not available` };
|
|
32766
32798
|
}
|
|
32799
|
+
const opts = { signal, timeoutMs };
|
|
32767
32800
|
try {
|
|
32768
32801
|
const result = await client.callTool({ name, arguments: args ?? {} }, void 0, { signal: opts.signal, timeout: opts.timeoutMs });
|
|
32769
32802
|
return mapToolResult(result);
|
|
@@ -32779,7 +32812,7 @@ var McpToolSource = class {
|
|
|
32779
32812
|
return { isError: true, content: `tool ${name} failed: unavailable` };
|
|
32780
32813
|
}
|
|
32781
32814
|
this.connectionLost(client, err);
|
|
32782
|
-
return
|
|
32815
|
+
return CONNECTION_LOST;
|
|
32783
32816
|
}
|
|
32784
32817
|
}
|
|
32785
32818
|
async close() {
|
|
@@ -32885,7 +32918,13 @@ var McpToolSource = class {
|
|
|
32885
32918
|
out.push({
|
|
32886
32919
|
name: t.name,
|
|
32887
32920
|
description: t.description ?? "",
|
|
32888
|
-
inputSchema: t.inputSchema
|
|
32921
|
+
inputSchema: t.inputSchema,
|
|
32922
|
+
...t.annotations ? {
|
|
32923
|
+
annotations: {
|
|
32924
|
+
readOnlyHint: t.annotations.readOnlyHint,
|
|
32925
|
+
idempotentHint: t.annotations.idempotentHint
|
|
32926
|
+
}
|
|
32927
|
+
} : {}
|
|
32889
32928
|
});
|
|
32890
32929
|
}
|
|
32891
32930
|
cursor = res.nextCursor;
|
|
@@ -32639,6 +32639,7 @@ function toolsHash(all) {
|
|
|
32639
32639
|
var DEFAULT_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 16e3, 3e4];
|
|
32640
32640
|
var MAX_LIST_PAGES = 10;
|
|
32641
32641
|
var REQUEST_TIMEOUT_CODE = -32001;
|
|
32642
|
+
var CONNECTION_LOST = Symbol("connection-lost");
|
|
32642
32643
|
function readPackageVersion() {
|
|
32643
32644
|
try {
|
|
32644
32645
|
const require2 = createRequire(import.meta.url);
|
|
@@ -32653,12 +32654,23 @@ function errorFields(err) {
|
|
|
32653
32654
|
if (err instanceof Error) {
|
|
32654
32655
|
const code = err.code;
|
|
32655
32656
|
const name = err.constructor.name || err.name;
|
|
32656
|
-
|
|
32657
|
+
const out = {
|
|
32657
32658
|
error: code !== void 0 ? `${name} ${String(code)}` : name
|
|
32658
32659
|
};
|
|
32660
|
+
const cause = err.cause;
|
|
32661
|
+
if (cause instanceof Error) {
|
|
32662
|
+
out.cause = cause.constructor.name || cause.name;
|
|
32663
|
+
const causeCode = cause.code;
|
|
32664
|
+
if (causeCode !== void 0)
|
|
32665
|
+
out.causeCode = String(causeCode);
|
|
32666
|
+
}
|
|
32667
|
+
return out;
|
|
32659
32668
|
}
|
|
32660
32669
|
return { error: typeof err };
|
|
32661
32670
|
}
|
|
32671
|
+
function retryableAfterReconnect(tool) {
|
|
32672
|
+
return tool?.annotations?.readOnlyHint === true || tool?.annotations?.idempotentHint === true;
|
|
32673
|
+
}
|
|
32662
32674
|
function urlOrigin(url2) {
|
|
32663
32675
|
try {
|
|
32664
32676
|
return new URL(url2).origin;
|
|
@@ -32760,10 +32772,31 @@ var McpToolSource = class {
|
|
|
32760
32772
|
return this.cached.map((t) => ({ ...t }));
|
|
32761
32773
|
}
|
|
32762
32774
|
async callTool(name, args, opts) {
|
|
32775
|
+
const deadline = Date.now() + opts.timeoutMs;
|
|
32776
|
+
const tool = this.cached.find((t) => t.name === name);
|
|
32777
|
+
const first = await this.callOnce(name, args, opts.signal, opts.timeoutMs);
|
|
32778
|
+
if (first !== CONNECTION_LOST)
|
|
32779
|
+
return first;
|
|
32780
|
+
const unavailable = {
|
|
32781
|
+
isError: true,
|
|
32782
|
+
content: `tool ${name} failed: unavailable`
|
|
32783
|
+
};
|
|
32784
|
+
if (!retryableAfterReconnect(tool) || opts.signal?.aborted)
|
|
32785
|
+
return unavailable;
|
|
32786
|
+
const reconnected = await this.ready(deadline - Date.now());
|
|
32787
|
+
const remaining = deadline - Date.now();
|
|
32788
|
+
if (!reconnected || remaining <= 0 || opts.signal?.aborted)
|
|
32789
|
+
return unavailable;
|
|
32790
|
+
const second = await this.callOnce(name, args, opts.signal, remaining);
|
|
32791
|
+
return second === CONNECTION_LOST ? unavailable : second;
|
|
32792
|
+
}
|
|
32793
|
+
/** One call on the current connection; CONNECTION_LOST when the transport failed. */
|
|
32794
|
+
async callOnce(name, args, signal, timeoutMs) {
|
|
32763
32795
|
const client = this.client;
|
|
32764
32796
|
if (this.state !== "ready" || !client || !this.cached.some((t) => t.name === name)) {
|
|
32765
32797
|
return { isError: true, content: `tool ${name} is not available` };
|
|
32766
32798
|
}
|
|
32799
|
+
const opts = { signal, timeoutMs };
|
|
32767
32800
|
try {
|
|
32768
32801
|
const result = await client.callTool({ name, arguments: args ?? {} }, void 0, { signal: opts.signal, timeout: opts.timeoutMs });
|
|
32769
32802
|
return mapToolResult(result);
|
|
@@ -32779,7 +32812,7 @@ var McpToolSource = class {
|
|
|
32779
32812
|
return { isError: true, content: `tool ${name} failed: unavailable` };
|
|
32780
32813
|
}
|
|
32781
32814
|
this.connectionLost(client, err);
|
|
32782
|
-
return
|
|
32815
|
+
return CONNECTION_LOST;
|
|
32783
32816
|
}
|
|
32784
32817
|
}
|
|
32785
32818
|
async close() {
|
|
@@ -32885,7 +32918,13 @@ var McpToolSource = class {
|
|
|
32885
32918
|
out.push({
|
|
32886
32919
|
name: t.name,
|
|
32887
32920
|
description: t.description ?? "",
|
|
32888
|
-
inputSchema: t.inputSchema
|
|
32921
|
+
inputSchema: t.inputSchema,
|
|
32922
|
+
...t.annotations ? {
|
|
32923
|
+
annotations: {
|
|
32924
|
+
readOnlyHint: t.annotations.readOnlyHint,
|
|
32925
|
+
idempotentHint: t.annotations.idempotentHint
|
|
32926
|
+
}
|
|
32927
|
+
} : {}
|
|
32889
32928
|
});
|
|
32890
32929
|
}
|
|
32891
32930
|
cursor = res.nextCursor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,KAAK,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAC1B,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,mFAAmF;IACnF,YAAY,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,uBAAuB,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,KAAK,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAC1B,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,aAAa,GAAG,OAAO,CAAC;AAE5D,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,mFAAmF;IACnF,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB,mFAAmF;IACnF,YAAY,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,uBAAuB,EAghBpD,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAMrE,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,eAAe,CAEnE;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,uBAAuB,CAMnE;AAED,wBAAgB,yBAAyB,IAAI,uBAAuB,EAAE,CAErE"}
|
|
@@ -87,13 +87,14 @@ export const AGENT_TEMPLATES = [
|
|
|
87
87
|
title: "Game sync (multi-object DC)",
|
|
88
88
|
summary: "Authoritative multi-object sync sample for real-time games.",
|
|
89
89
|
category: "data",
|
|
90
|
-
description: "Authoritative multi-object sync
|
|
90
|
+
description: "Authoritative multi-object sync: 60 Hz sim, 30 Hz quantized int16 binary frames (live objects only); uses Redis when AGENT_REDIS_URL is set.",
|
|
91
91
|
sourceFiles: [
|
|
92
92
|
"game-sync/agent.ts",
|
|
93
93
|
"game-sync/protocol.ts",
|
|
94
94
|
"game-sync/world-layout.ts",
|
|
95
95
|
"game-sync/sim.ts",
|
|
96
96
|
"game-sync/redis.ts",
|
|
97
|
+
"game-sync/quantize.ts",
|
|
97
98
|
],
|
|
98
99
|
npmDependencies: { ioredis: "^5.11.1" },
|
|
99
100
|
},
|
|
@@ -455,8 +456,12 @@ export const AGENT_TEMPLATES = [
|
|
|
455
456
|
title: "Redis sync",
|
|
456
457
|
summary: "Redis-backed world buffer sync for redis-sync-smoke.",
|
|
457
458
|
category: "debug",
|
|
458
|
-
description: "Redis-backed world
|
|
459
|
-
sourceFiles: [
|
|
459
|
+
description: "Redis-backed world sync for redis-sync-smoke — 12-byte position frames in, quantized delta and keyframe frames out, project Redis SETRANGE.",
|
|
460
|
+
sourceFiles: [
|
|
461
|
+
"redis-sync/agent.ts",
|
|
462
|
+
"redis-sync/world-layout.ts",
|
|
463
|
+
"redis-sync/quantize.ts",
|
|
464
|
+
],
|
|
460
465
|
npmDependencies: { ioredis: "^5.11.1" },
|
|
461
466
|
},
|
|
462
467
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,0DAA0D;QACnE,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,8EAA8E;QAChF,WAAW,EAAE,CAAC,eAAe,CAAC;KAC/B;IACD;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,kBAAkB;QACzB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,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AAY,EAAE,IAAI;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EACL,4EAA4E;QAC9E,QAAQ,EAAE,MAAM;QAChB,WAAW,EACT,wGAAwG;QAC1G,WAAW,EAAE;YACX,4BAA4B;YAC5B,+BAA+B;SAChC;KACF;IACD;QACE,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,oBAAoB;QAC3B,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,6BAA6B;QACpC,OAAO,EAAE,6DAA6D;QACtE,QAAQ,EAAE,MAAM;QAChB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/templates/registry.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,eAAe,GAAuC;IACjE;QACE,EAAE,EAAE,MAAM;QACV,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,qBAAqB;QAC5B,OAAO,EAAE,0DAA0D;QACnE,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,8EAA8E;QAChF,WAAW,EAAE,CAAC,eAAe,CAAC;KAC/B;IACD;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,kBAAkB;QACzB,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,6BAA6B;QACpC,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qEAAqE;QACvE,WAAW,EAAE,CAAC,kBAAkB,CAAC;KAClC;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,0BAA0B;QACjC,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,iBAAiB;QACxB,OAAO,EACL,qIAAqI;QACvI,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,qVAAqV;QACvV,WAAW,EAAE,CAAC,0BAA0B,CAAC;K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EAAE,oBAAoB;QAC3B,IAAI,EAAE,KAAK;QACX,YAAY,EAAE,KAAK;QACnB,KAAK,EAAE,WAAW;QAClB,OAAO,EACL,iFAAiF;QACnF,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,iFAAiF;QACnF,WAAW,EAAE,CAAC,oBAAoB,CAAC;KACpC;CACO,CAAC;AAIX,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,eAAe,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAC3D,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,OAAO,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -1377,7 +1377,11 @@ function agentLog(level, message, fieldsOrSessionId, sessionId) {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
|
|
1379
1379
|
// templates/world-sync/agent.ts
|
|
1380
|
+
var BROADCAST_HZ = 30;
|
|
1381
|
+
var BROADCAST_INTERVAL_MS = Math.floor(1e3 / BROADCAST_HZ);
|
|
1380
1382
|
var poses = /* @__PURE__ */ new Map();
|
|
1383
|
+
var dirty = false;
|
|
1384
|
+
var broadcastTimer = null;
|
|
1381
1385
|
function isFiniteNumber(value) {
|
|
1382
1386
|
return typeof value === "number" && Number.isFinite(value);
|
|
1383
1387
|
}
|
|
@@ -1395,6 +1399,7 @@ function parsePoseMessage(message) {
|
|
|
1395
1399
|
return { x: record.x, y: record.y, z: record.z };
|
|
1396
1400
|
}
|
|
1397
1401
|
function broadcastWorld() {
|
|
1402
|
+
dirty = false;
|
|
1398
1403
|
const payload = {
|
|
1399
1404
|
type: "world",
|
|
1400
1405
|
poses: Object.fromEntries(poses)
|
|
@@ -1403,23 +1408,39 @@ function broadcastWorld() {
|
|
|
1403
1408
|
sendToClient(sessionId, payload);
|
|
1404
1409
|
}
|
|
1405
1410
|
}
|
|
1411
|
+
function startTickIfNeeded() {
|
|
1412
|
+
if (broadcastTimer || poses.size === 0) return;
|
|
1413
|
+
broadcastTimer = setInterval(() => {
|
|
1414
|
+
if (dirty) broadcastWorld();
|
|
1415
|
+
}, BROADCAST_INTERVAL_MS);
|
|
1416
|
+
}
|
|
1417
|
+
function stopTickIfIdle() {
|
|
1418
|
+
if (poses.size > 0 || !broadcastTimer) return;
|
|
1419
|
+
clearInterval(broadcastTimer);
|
|
1420
|
+
broadcastTimer = null;
|
|
1421
|
+
dirty = false;
|
|
1422
|
+
}
|
|
1406
1423
|
var agent_default = defineAgent({
|
|
1407
1424
|
onClientJoin({ sessionId }) {
|
|
1408
1425
|
poses.set(sessionId, { x: 0, y: 0, z: 0 });
|
|
1426
|
+
startTickIfNeeded();
|
|
1409
1427
|
broadcastWorld();
|
|
1410
1428
|
},
|
|
1411
1429
|
onClientLeave({ sessionId }) {
|
|
1412
1430
|
poses.delete(sessionId);
|
|
1413
1431
|
broadcastWorld();
|
|
1432
|
+
stopTickIfIdle();
|
|
1414
1433
|
},
|
|
1415
1434
|
onDataChannelMessage({ sessionId, message }) {
|
|
1416
1435
|
const pose = parsePoseMessage(message);
|
|
1417
1436
|
if (!pose) return;
|
|
1418
1437
|
poses.set(sessionId, pose);
|
|
1419
|
-
|
|
1438
|
+
startTickIfNeeded();
|
|
1439
|
+
dirty = true;
|
|
1420
1440
|
}
|
|
1421
1441
|
});
|
|
1422
1442
|
export {
|
|
1443
|
+
BROADCAST_HZ,
|
|
1423
1444
|
agent_default as default,
|
|
1424
1445
|
isFiniteNumber,
|
|
1425
1446
|
parsePoseMessage
|