@strayl/agent 0.1.1 → 0.1.3

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/agent.js CHANGED
@@ -12044,14 +12044,13 @@ function runFind(pattern, searchPath, workDir) {
12044
12044
  async function proxyFetch(service, directUrl, directApiKey, init, env) {
12045
12045
  if (env.STRAYL_LLM_DIRECT === "1") {
12046
12046
  const key = env[directApiKey];
12047
- if (!key) {
12048
- throw new Error(`${directApiKey} not configured (direct mode)`);
12049
- }
12050
- const headers2 = new Headers(init.headers);
12051
- if (!headers2.has("Authorization")) {
12052
- headers2.set("Authorization", `Bearer ${key}`);
12047
+ if (key) {
12048
+ const headers2 = new Headers(init.headers);
12049
+ if (!headers2.has("Authorization")) {
12050
+ headers2.set("Authorization", `Bearer ${key}`);
12051
+ }
12052
+ return fetch(directUrl, { ...init, headers: headers2 });
12053
12053
  }
12054
- return fetch(directUrl, { ...init, headers: headers2 });
12055
12054
  }
12056
12055
  const apiUrl = env.STRAYL_API_URL ?? "https://api.strayl.dev";
12057
12056
  const token = env.STRAYL_SESSION_TOKEN ?? "";
@@ -12231,6 +12230,19 @@ var SubAgentManager = class {
12231
12230
  break;
12232
12231
  }
12233
12232
  for (const tc of toolCalls) {
12233
+ let parsedArgs;
12234
+ try {
12235
+ parsedArgs = JSON.parse(tc.function.arguments);
12236
+ } catch {
12237
+ parsedArgs = {};
12238
+ }
12239
+ this.emitter.emit({
12240
+ type: "tool-call-start",
12241
+ id: tc.id,
12242
+ name: tc.function.name,
12243
+ args: parsedArgs,
12244
+ _subagent: id
12245
+ });
12234
12246
  const ctx = {
12235
12247
  emitter: this.emitter,
12236
12248
  workDir: config.workDir,
@@ -12239,6 +12251,13 @@ var SubAgentManager = class {
12239
12251
  toolCallId: tc.id
12240
12252
  };
12241
12253
  const output = await executeTool(registry, tc, ctx, []);
12254
+ this.emitter.emit({
12255
+ type: "tool-result",
12256
+ id: tc.id,
12257
+ name: tc.function.name,
12258
+ output,
12259
+ _subagent: id
12260
+ });
12242
12261
  messages.push({
12243
12262
  role: "tool",
12244
12263
  content: output,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strayl/agent",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -117,6 +117,18 @@ export class SubAgentManager {
117
117
 
118
118
  // Execute tool calls
119
119
  for (const tc of toolCalls) {
120
+ let parsedArgs: unknown;
121
+ try { parsedArgs = JSON.parse(tc.function.arguments); } catch { parsedArgs = {}; }
122
+
123
+ // Emit with _subagent tag so app can associate with this subagent
124
+ (this.emitter as { emit(e: Record<string, unknown>): void }).emit({
125
+ type: "tool-call-start",
126
+ id: tc.id,
127
+ name: tc.function.name,
128
+ args: parsedArgs,
129
+ _subagent: id,
130
+ });
131
+
120
132
  const ctx = {
121
133
  emitter: this.emitter,
122
134
  workDir: config.workDir,
@@ -125,6 +137,15 @@ export class SubAgentManager {
125
137
  toolCallId: tc.id,
126
138
  };
127
139
  const output = await executeTool(registry, tc, ctx, []);
140
+
141
+ (this.emitter as { emit(e: Record<string, unknown>): void }).emit({
142
+ type: "tool-result",
143
+ id: tc.id,
144
+ name: tc.function.name,
145
+ output,
146
+ _subagent: id,
147
+ });
148
+
128
149
  messages.push({
129
150
  role: "tool",
130
151
  content: output,
@@ -26,16 +26,16 @@ export async function proxyFetch(
26
26
  env: Record<string, string>,
27
27
  ): Promise<Response> {
28
28
  if (env.STRAYL_LLM_DIRECT === "1") {
29
- // Direct mode — use raw API key
29
+ // Direct mode — use raw API key if available, otherwise fall back to proxy
30
30
  const key = env[directApiKey];
31
- if (!key) {
32
- throw new Error(`${directApiKey} not configured (direct mode)`);
31
+ if (key) {
32
+ const headers = new Headers(init.headers);
33
+ if (!headers.has("Authorization")) {
34
+ headers.set("Authorization", `Bearer ${key}`);
35
+ }
36
+ return fetch(directUrl, { ...init, headers });
33
37
  }
34
- const headers = new Headers(init.headers);
35
- if (!headers.has("Authorization")) {
36
- headers.set("Authorization", `Bearer ${key}`);
37
- }
38
- return fetch(directUrl, { ...init, headers });
38
+ // Key not in env — fall through to proxy mode
39
39
  }
40
40
 
41
41
  // Proxy mode — route through api.strayl.dev