@obrain/cli 0.1.9 → 0.1.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/dist/index.js +47 -29
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -72268,6 +72268,8 @@ var createRemoteDevice = async (config2, trpcUrlOverride) => {
|
|
|
72268
72268
|
};
|
|
72269
72269
|
|
|
72270
72270
|
// src/lib/agents/card.ts
|
|
72271
|
+
var AGENT_CARD_FETCH_RETRY_DELAY_MS = 1000;
|
|
72272
|
+
var AGENT_CARD_FETCH_MAX_RETRIES = 3;
|
|
72271
72273
|
var normalizeAgentCard = (value) => {
|
|
72272
72274
|
if (!value || typeof value !== "object") {
|
|
72273
72275
|
throw new Error("Agent card is not an object.");
|
|
@@ -72340,19 +72342,25 @@ var fetchAgentCard = async (cardUrl) => {
|
|
|
72340
72342
|
const candidates = resolvedCardUrl === cardUrl ? [cardUrl] : [resolvedCardUrl, cardUrl];
|
|
72341
72343
|
let lastError = null;
|
|
72342
72344
|
for (const url2 of candidates) {
|
|
72343
|
-
|
|
72344
|
-
|
|
72345
|
-
|
|
72346
|
-
|
|
72347
|
-
|
|
72345
|
+
for (let attempt = 0;attempt <= AGENT_CARD_FETCH_MAX_RETRIES; attempt += 1) {
|
|
72346
|
+
try {
|
|
72347
|
+
const response = await fetch(url2, {
|
|
72348
|
+
headers: {
|
|
72349
|
+
accept: "application/json",
|
|
72350
|
+
Authorization: `Bearer ${config2.token}`
|
|
72351
|
+
}
|
|
72352
|
+
});
|
|
72353
|
+
if (!response.ok) {
|
|
72354
|
+
throw new Error(`Failed to fetch agent card (${response.status}).`);
|
|
72348
72355
|
}
|
|
72349
|
-
|
|
72350
|
-
|
|
72351
|
-
|
|
72356
|
+
return { card: normalizeAgentCard(await response.json()), cardUrl: url2 };
|
|
72357
|
+
} catch (error51) {
|
|
72358
|
+
lastError = error51;
|
|
72359
|
+
if (attempt === AGENT_CARD_FETCH_MAX_RETRIES) {
|
|
72360
|
+
break;
|
|
72361
|
+
}
|
|
72362
|
+
await Bun.sleep(AGENT_CARD_FETCH_RETRY_DELAY_MS);
|
|
72352
72363
|
}
|
|
72353
|
-
return { card: normalizeAgentCard(await response.json()), cardUrl: url2 };
|
|
72354
|
-
} catch (error51) {
|
|
72355
|
-
lastError = error51;
|
|
72356
72364
|
}
|
|
72357
72365
|
}
|
|
72358
72366
|
throw lastError ?? new Error("Failed to fetch agent card.");
|
|
@@ -72680,14 +72688,20 @@ var appRouter = t.router({
|
|
|
72680
72688
|
})).mutation(async ({ ctx, input }) => {
|
|
72681
72689
|
try {
|
|
72682
72690
|
if (!input.localUrl) {
|
|
72691
|
+
const results = await ctx.runtimeManager.reloadAll();
|
|
72692
|
+
if (results.length > 0) {
|
|
72693
|
+
ctx.connector.requestReconnect("agent runtimes reloaded");
|
|
72694
|
+
}
|
|
72683
72695
|
return {
|
|
72684
72696
|
reloadedAll: true,
|
|
72685
|
-
results
|
|
72697
|
+
results
|
|
72686
72698
|
};
|
|
72687
72699
|
}
|
|
72700
|
+
const result = await ctx.runtimeManager.reloadByLocalUrl(input.localUrl);
|
|
72701
|
+
ctx.connector.requestReconnect(`agent runtime reloaded: ${input.localUrl}`);
|
|
72688
72702
|
return {
|
|
72689
72703
|
reloadedAll: false,
|
|
72690
|
-
result
|
|
72704
|
+
result
|
|
72691
72705
|
};
|
|
72692
72706
|
} catch (error51) {
|
|
72693
72707
|
const message = error51.message;
|
|
@@ -77498,9 +77512,7 @@ var userSandbox = pgTable("user_sandbox", {
|
|
|
77498
77512
|
createdAt: timestamp("created_at").notNull(),
|
|
77499
77513
|
updatedAt: timestamp("updated_at").$onUpdate(() => new Date).notNull()
|
|
77500
77514
|
}, (table) => [
|
|
77501
|
-
primaryKey({ columns: [table.userId, table.sandboxId] })
|
|
77502
|
-
index("user_sandbox_user_id_idx").on(table.userId),
|
|
77503
|
-
uniqueIndex("user_sandbox_sandbox_id_idx").on(table.sandboxId)
|
|
77515
|
+
primaryKey({ columns: [table.userId, table.sandboxId] })
|
|
77504
77516
|
]);
|
|
77505
77517
|
var cliDevice = pgTable("cli_device", {
|
|
77506
77518
|
id: text("id").primaryKey(),
|
|
@@ -77571,7 +77583,7 @@ var userExternalGroup = pgTable("user_external_group", {
|
|
|
77571
77583
|
})
|
|
77572
77584
|
]);
|
|
77573
77585
|
var userGroupAgentConfig = pgTable("user_group_agent_config", {
|
|
77574
|
-
userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),
|
|
77586
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
77575
77587
|
conversationId: text("conversation_id").notNull(),
|
|
77576
77588
|
agentId: text("agent_id").notNull(),
|
|
77577
77589
|
isShared: boolean4("is_shared").notNull().default(true),
|
|
@@ -79513,23 +79525,29 @@ var runAgentRuntime = async (input) => {
|
|
|
79513
79525
|
const agentCard = await agent.buildAgentCard();
|
|
79514
79526
|
const { server: server2 } = await startServer({ authService, port: input.port }, agentCard, agent);
|
|
79515
79527
|
await writeReadyState({ status: "ready" });
|
|
79528
|
+
let shutdownPromise = null;
|
|
79516
79529
|
const shutdown = async () => {
|
|
79517
|
-
|
|
79518
|
-
|
|
79519
|
-
|
|
79520
|
-
|
|
79521
|
-
|
|
79522
|
-
|
|
79523
|
-
|
|
79524
|
-
|
|
79530
|
+
if (shutdownPromise) {
|
|
79531
|
+
return shutdownPromise;
|
|
79532
|
+
}
|
|
79533
|
+
shutdownPromise = (async () => {
|
|
79534
|
+
await agent.close();
|
|
79535
|
+
await new Promise((resolve7, reject) => {
|
|
79536
|
+
server2.close((error51) => {
|
|
79537
|
+
if (error51) {
|
|
79538
|
+
reject(error51);
|
|
79539
|
+
return;
|
|
79540
|
+
}
|
|
79541
|
+
resolve7();
|
|
79542
|
+
});
|
|
79525
79543
|
});
|
|
79526
|
-
});
|
|
79527
|
-
|
|
79544
|
+
})();
|
|
79545
|
+
return shutdownPromise;
|
|
79528
79546
|
};
|
|
79529
|
-
process.
|
|
79547
|
+
process.once("SIGTERM", () => {
|
|
79530
79548
|
shutdown();
|
|
79531
79549
|
});
|
|
79532
|
-
process.
|
|
79550
|
+
process.once("SIGINT", () => {
|
|
79533
79551
|
shutdown();
|
|
79534
79552
|
});
|
|
79535
79553
|
await new Promise(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obrain/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"@types/node": "^20.14.15",
|
|
23
23
|
"@types/yargs": "17.0.35",
|
|
24
24
|
"bun-types": "^1.1.28",
|
|
25
|
-
"@repo/
|
|
25
|
+
"@repo/better-auth": "0.0.0",
|
|
26
26
|
"@repo/trpc": "0.0.0",
|
|
27
|
-
"@repo/
|
|
27
|
+
"@repo/a2a": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "bun build src/index.ts --outfile dist/index.js --target bun",
|