@meistrari/tela-cli 0.7.45 → 0.7.46
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.js +84 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1642,6 +1642,9 @@ var require_agent_api = __commonJS({
|
|
|
1642
1642
|
exports2.fetchRepositoryLookup = fetchRepositoryLookup;
|
|
1643
1643
|
exports2.fetchCommitFeedback = fetchCommitFeedback;
|
|
1644
1644
|
exports2.listTelaAgents = listTelaAgents;
|
|
1645
|
+
exports2.listAgentRunHistory = listAgentRunHistory;
|
|
1646
|
+
exports2.fetchAgentRunDetail = fetchAgentRunDetail;
|
|
1647
|
+
exports2.searchAgentRuns = searchAgentRuns;
|
|
1645
1648
|
exports2.listAvailableRepositories = listAvailableRepositories;
|
|
1646
1649
|
var tela_local_config_1 = require_dist();
|
|
1647
1650
|
var auth_1 = require_auth2();
|
|
@@ -1853,6 +1856,82 @@ var require_agent_api = __commonJS({
|
|
|
1853
1856
|
}
|
|
1854
1857
|
return payload.data;
|
|
1855
1858
|
}
|
|
1859
|
+
function isAgentRunHistoryItem(value) {
|
|
1860
|
+
if (!value || typeof value !== "object") {
|
|
1861
|
+
return false;
|
|
1862
|
+
}
|
|
1863
|
+
const candidate = value;
|
|
1864
|
+
return typeof candidate.id === "string" && typeof candidate.sessionId === "string" && typeof candidate.status === "string" && typeof candidate.provider === "string" && (typeof candidate.calculatedCostUsd === "number" || candidate.calculatedCostUsd === null) && typeof candidate.executionSurface === "string" && typeof candidate.createdAt === "string";
|
|
1865
|
+
}
|
|
1866
|
+
async function listAgentRunHistory(config, options, fetchFn = fetch) {
|
|
1867
|
+
const headers = await (0, auth_1.buildAgentApiHeaders)(config, { fetchFn });
|
|
1868
|
+
const url = new URL(joinUrl2(config.agentApiUrl, "/v3/runs"));
|
|
1869
|
+
if (options?.agentRepoId) {
|
|
1870
|
+
url.searchParams.set("agentRepoId", options.agentRepoId);
|
|
1871
|
+
}
|
|
1872
|
+
if (options?.status) {
|
|
1873
|
+
url.searchParams.set("status", options.status);
|
|
1874
|
+
}
|
|
1875
|
+
if (options?.cursor) {
|
|
1876
|
+
url.searchParams.set("cursor", options.cursor);
|
|
1877
|
+
}
|
|
1878
|
+
if (options?.limit != null) {
|
|
1879
|
+
url.searchParams.set("limit", String(options.limit));
|
|
1880
|
+
}
|
|
1881
|
+
const response = await fetchFn(url.toString(), {
|
|
1882
|
+
method: "GET",
|
|
1883
|
+
headers,
|
|
1884
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS)
|
|
1885
|
+
});
|
|
1886
|
+
const responseText = await response.text();
|
|
1887
|
+
const payload = parseJsonBody(responseText);
|
|
1888
|
+
if (!response.ok) {
|
|
1889
|
+
throw new AgentApiError(payload?.error ?? `Agent API run history listing failed with status ${response.status}`, response.status, responseText);
|
|
1890
|
+
}
|
|
1891
|
+
if (!payload || !Array.isArray(payload.runs) || !payload.runs.every(isAgentRunHistoryItem)) {
|
|
1892
|
+
throw new AgentApiError("Agent API run history listing returned an invalid payload", response.status, responseText);
|
|
1893
|
+
}
|
|
1894
|
+
return {
|
|
1895
|
+
runs: payload.runs,
|
|
1896
|
+
nextCursor: payload.nextCursor ?? null
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
async function fetchAgentRunDetail(runId, config, fetchFn = fetch) {
|
|
1900
|
+
const headers = await (0, auth_1.buildAgentApiHeaders)(config, { fetchFn });
|
|
1901
|
+
const response = await fetchFn(joinUrl2(config.agentApiUrl, `/v3/runs/${encodeURIComponent(runId)}`), {
|
|
1902
|
+
method: "GET",
|
|
1903
|
+
headers,
|
|
1904
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS)
|
|
1905
|
+
});
|
|
1906
|
+
const responseText = await response.text();
|
|
1907
|
+
const payload = parseJsonBody(responseText);
|
|
1908
|
+
if (!response.ok) {
|
|
1909
|
+
throw new AgentApiError(payload?.error ?? `Agent API run detail failed with status ${response.status}`, response.status, responseText);
|
|
1910
|
+
}
|
|
1911
|
+
if (!payload || !isAgentRunHistoryItem(payload)) {
|
|
1912
|
+
throw new AgentApiError("Agent API run detail returned an invalid payload", response.status, responseText);
|
|
1913
|
+
}
|
|
1914
|
+
return payload;
|
|
1915
|
+
}
|
|
1916
|
+
async function searchAgentRuns(query, config, options, fetchFn = fetch) {
|
|
1917
|
+
const headers = await (0, auth_1.buildAgentApiHeaders)(config, { fetchFn });
|
|
1918
|
+
const url = new URL(joinUrl2(config.agentApiUrl, "/v3/runs/search"));
|
|
1919
|
+
url.searchParams.set("q", query);
|
|
1920
|
+
if (options?.limit != null) {
|
|
1921
|
+
url.searchParams.set("limit", String(options.limit));
|
|
1922
|
+
}
|
|
1923
|
+
const response = await fetchFn(url.toString(), {
|
|
1924
|
+
method: "GET",
|
|
1925
|
+
headers,
|
|
1926
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS)
|
|
1927
|
+
});
|
|
1928
|
+
const responseText = await response.text();
|
|
1929
|
+
const payload = parseJsonBody(responseText);
|
|
1930
|
+
if (!response.ok) {
|
|
1931
|
+
throw new AgentApiError(payload?.error ?? `Agent API run search failed with status ${response.status}`, response.status, responseText);
|
|
1932
|
+
}
|
|
1933
|
+
return payload ?? { results: [] };
|
|
1934
|
+
}
|
|
1856
1935
|
async function listAvailableRepositories(config, fetchFn = fetch) {
|
|
1857
1936
|
const headers = await (0, auth_1.buildAgentApiHeaders)(config, { fetchFn });
|
|
1858
1937
|
const response = await fetchFn(joinUrl2(config.agentApiUrl, "/v3/agents/repositories"), {
|
|
@@ -4920,10 +4999,10 @@ ${detail.errors.join("\n")}` : summary);
|
|
|
4920
4999
|
function buildOpenRouterProxyBaseUrl(agentApiUrl) {
|
|
4921
5000
|
return new URL("/v3/openrouter", agentApiUrl.endsWith("/") ? agentApiUrl : `${agentApiUrl}/`).toString().replace(/\/$/, "");
|
|
4922
5001
|
}
|
|
4923
|
-
function buildOpenRouterClaudeEnvironmentOverrides(model, dataToken, agentApiUrl) {
|
|
4924
|
-
const proxyBaseUrl = buildOpenRouterProxyBaseUrl(agentApiUrl);
|
|
5002
|
+
function buildOpenRouterClaudeEnvironmentOverrides(model, dataToken, agentApiUrl, sessionId) {
|
|
4925
5003
|
return {
|
|
4926
|
-
ANTHROPIC_BASE_URL:
|
|
5004
|
+
ANTHROPIC_BASE_URL: buildOpenRouterProxyBaseUrl(agentApiUrl),
|
|
5005
|
+
...sessionId ? { ANTHROPIC_CUSTOM_HEADERS: `x-agent-session-id: ${sessionId}` } : {},
|
|
4927
5006
|
ANTHROPIC_AUTH_TOKEN: dataToken,
|
|
4928
5007
|
ANTHROPIC_API_KEY: "",
|
|
4929
5008
|
ANTHROPIC_DEFAULT_OPUS_MODEL: model,
|
|
@@ -4982,7 +5061,8 @@ ${detail.errors.join("\n")}` : summary);
|
|
|
4982
5061
|
};
|
|
4983
5062
|
const models = await fetchModelsFn(config, options.fetch, { headers });
|
|
4984
5063
|
await ensureOpenRouterModelAvailable(model, models);
|
|
4985
|
-
const
|
|
5064
|
+
const agentSessionId = `local-${(0, node_crypto_1.randomUUID)()}`;
|
|
5065
|
+
const environmentOverrides = buildOpenRouterClaudeEnvironmentOverrides(model, dataToken, config.agentApiUrl, agentSessionId);
|
|
4986
5066
|
const redactedEnvironmentOverrides = redactClaudeEnvironmentOverrides(environmentOverrides);
|
|
4987
5067
|
return {
|
|
4988
5068
|
command,
|