@mitralab.io/sdk-core 0.3.3 → 0.3.4
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/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/contracts/README.md +5 -0
- package/contracts/manifest.json +6 -1
- package/contracts/v0.3.4/sdk-parity.json +2902 -0
- package/dist/index.cjs +19 -11
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +19 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4377,6 +4377,7 @@ var TURN_TAIL_TYPES = /* @__PURE__ */ new Set([
|
|
|
4377
4377
|
"toolResult",
|
|
4378
4378
|
"stepFinish"
|
|
4379
4379
|
]);
|
|
4380
|
+
var STATE_FRAME_TYPES = /* @__PURE__ */ new Set(["providerUsage", "backgroundTasks"]);
|
|
4380
4381
|
var COPILOT_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
4381
4382
|
"message",
|
|
4382
4383
|
"interrupt",
|
|
@@ -4498,6 +4499,10 @@ var REQUEST_ROW_KINDS = {
|
|
|
4498
4499
|
USER_INPUT_REQUEST: "userInputRequest",
|
|
4499
4500
|
NOTIFICATION: "notification"
|
|
4500
4501
|
};
|
|
4502
|
+
function notificationFieldsOf(payload) {
|
|
4503
|
+
const { source, outcome, summary, detail } = payload;
|
|
4504
|
+
return { source, outcome, summary, ...detail !== void 0 ? { detail } : {} };
|
|
4505
|
+
}
|
|
4501
4506
|
function parseJson(text) {
|
|
4502
4507
|
try {
|
|
4503
4508
|
return JSON.parse(text);
|
|
@@ -4520,14 +4525,14 @@ function toAgentTimelineItem(message) {
|
|
|
4520
4525
|
if (requestKind) {
|
|
4521
4526
|
const payload = asObject2(parseJson(message.content));
|
|
4522
4527
|
if (payload) {
|
|
4523
|
-
|
|
4528
|
+
const item = {
|
|
4524
4529
|
id: message.id,
|
|
4525
|
-
kind: requestKind,
|
|
4526
4530
|
payload,
|
|
4527
4531
|
at: message.createdAt,
|
|
4528
4532
|
...timelineIdentityOf(message),
|
|
4529
4533
|
...parentToolIdOf(message.parentToolId)
|
|
4530
4534
|
};
|
|
4535
|
+
return requestKind === "notification" ? { ...item, kind: requestKind, ...notificationFieldsOf(payload) } : { ...item, kind: requestKind };
|
|
4531
4536
|
}
|
|
4532
4537
|
}
|
|
4533
4538
|
if (message.type === "TOOL_USE") {
|
|
@@ -5544,6 +5549,7 @@ var CoreAgentTaskSession = class {
|
|
|
5544
5549
|
}
|
|
5545
5550
|
repeatsTheRunningTurn(event, lifecycle) {
|
|
5546
5551
|
if (this._status !== "streaming" && this._status !== "cancelled") return false;
|
|
5552
|
+
if (STATE_FRAME_TYPES.has(event.type)) return false;
|
|
5547
5553
|
const turnId = lifecycle?.turnId;
|
|
5548
5554
|
if (typeof turnId !== "string") return false;
|
|
5549
5555
|
if (typeof event.sequence === "number") {
|
|
@@ -5680,15 +5686,17 @@ var CoreAgentTaskSession = class {
|
|
|
5680
5686
|
if (itemId === void 0 && sequence === void 0) return;
|
|
5681
5687
|
this.livePiece(
|
|
5682
5688
|
(item) => item.kind === kind && (itemId !== void 0 ? item.itemId === itemId : item.sequence === sequence),
|
|
5683
|
-
() =>
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5689
|
+
() => {
|
|
5690
|
+
const item = {
|
|
5691
|
+
id: `live:${kind}:${itemId ?? sequence}`,
|
|
5692
|
+
payload,
|
|
5693
|
+
at: liveAtOf(event),
|
|
5694
|
+
...sequence === void 0 ? {} : { sequence },
|
|
5695
|
+
...itemId === void 0 ? {} : { itemId },
|
|
5696
|
+
...parentToolIdOf(parentToolId)
|
|
5697
|
+
};
|
|
5698
|
+
return kind === "notification" ? { ...item, kind, ...notificationFieldsOf(payload) } : { ...item, kind };
|
|
5699
|
+
},
|
|
5692
5700
|
(item) => item
|
|
5693
5701
|
);
|
|
5694
5702
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1232,7 +1232,7 @@ interface AgentMessage {
|
|
|
1232
1232
|
sender: string;
|
|
1233
1233
|
/**
|
|
1234
1234
|
* `TEXT`, `ERROR`, `TOOL_USE`; asked with `kinds: "all"`, also `REASONING`, `SUBAGENT_TEXT`,
|
|
1235
|
-
* `APPROVAL` and `
|
|
1235
|
+
* `APPROVAL`, `USER_INPUT_REQUEST` and `NOTIFICATION`.
|
|
1236
1236
|
*/
|
|
1237
1237
|
type: string;
|
|
1238
1238
|
content: string;
|
|
@@ -2442,14 +2442,14 @@ type AgentTimelineItem = ({
|
|
|
2442
2442
|
id: string;
|
|
2443
2443
|
/**
|
|
2444
2444
|
* Background work that ended (a command, a subagent, a monitor), the item T3 puts in the turn
|
|
2445
|
-
* the provider opens for it (`NOTIFICATION` row):
|
|
2446
|
-
*
|
|
2445
|
+
* the provider opens for it (`NOTIFICATION` row): `source`, `outcome`, `summary` and `detail`
|
|
2446
|
+
* as the live `notification` event carries them, and the box's frame as it came in `payload`.
|
|
2447
2447
|
*/
|
|
2448
2448
|
kind: "notification";
|
|
2449
2449
|
payload: Record<string, unknown>;
|
|
2450
2450
|
at: string;
|
|
2451
2451
|
parentToolId?: string;
|
|
2452
|
-
} & AgentTimelineItemIdentity) | ({
|
|
2452
|
+
} & Pick<AgentNotification, "source" | "outcome" | "summary" | "detail"> & AgentTimelineItemIdentity) | ({
|
|
2453
2453
|
id: string;
|
|
2454
2454
|
kind: "tool";
|
|
2455
2455
|
tool: AgentToolEvent;
|
package/dist/index.d.ts
CHANGED
|
@@ -1232,7 +1232,7 @@ interface AgentMessage {
|
|
|
1232
1232
|
sender: string;
|
|
1233
1233
|
/**
|
|
1234
1234
|
* `TEXT`, `ERROR`, `TOOL_USE`; asked with `kinds: "all"`, also `REASONING`, `SUBAGENT_TEXT`,
|
|
1235
|
-
* `APPROVAL` and `
|
|
1235
|
+
* `APPROVAL`, `USER_INPUT_REQUEST` and `NOTIFICATION`.
|
|
1236
1236
|
*/
|
|
1237
1237
|
type: string;
|
|
1238
1238
|
content: string;
|
|
@@ -2442,14 +2442,14 @@ type AgentTimelineItem = ({
|
|
|
2442
2442
|
id: string;
|
|
2443
2443
|
/**
|
|
2444
2444
|
* Background work that ended (a command, a subagent, a monitor), the item T3 puts in the turn
|
|
2445
|
-
* the provider opens for it (`NOTIFICATION` row):
|
|
2446
|
-
*
|
|
2445
|
+
* the provider opens for it (`NOTIFICATION` row): `source`, `outcome`, `summary` and `detail`
|
|
2446
|
+
* as the live `notification` event carries them, and the box's frame as it came in `payload`.
|
|
2447
2447
|
*/
|
|
2448
2448
|
kind: "notification";
|
|
2449
2449
|
payload: Record<string, unknown>;
|
|
2450
2450
|
at: string;
|
|
2451
2451
|
parentToolId?: string;
|
|
2452
|
-
} & AgentTimelineItemIdentity) | ({
|
|
2452
|
+
} & Pick<AgentNotification, "source" | "outcome" | "summary" | "detail"> & AgentTimelineItemIdentity) | ({
|
|
2453
2453
|
id: string;
|
|
2454
2454
|
kind: "tool";
|
|
2455
2455
|
tool: AgentToolEvent;
|
package/dist/index.js
CHANGED
|
@@ -4305,6 +4305,7 @@ var TURN_TAIL_TYPES = /* @__PURE__ */ new Set([
|
|
|
4305
4305
|
"toolResult",
|
|
4306
4306
|
"stepFinish"
|
|
4307
4307
|
]);
|
|
4308
|
+
var STATE_FRAME_TYPES = /* @__PURE__ */ new Set(["providerUsage", "backgroundTasks"]);
|
|
4308
4309
|
var COPILOT_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
4309
4310
|
"message",
|
|
4310
4311
|
"interrupt",
|
|
@@ -4426,6 +4427,10 @@ var REQUEST_ROW_KINDS = {
|
|
|
4426
4427
|
USER_INPUT_REQUEST: "userInputRequest",
|
|
4427
4428
|
NOTIFICATION: "notification"
|
|
4428
4429
|
};
|
|
4430
|
+
function notificationFieldsOf(payload) {
|
|
4431
|
+
const { source, outcome, summary, detail } = payload;
|
|
4432
|
+
return { source, outcome, summary, ...detail !== void 0 ? { detail } : {} };
|
|
4433
|
+
}
|
|
4429
4434
|
function parseJson(text) {
|
|
4430
4435
|
try {
|
|
4431
4436
|
return JSON.parse(text);
|
|
@@ -4448,14 +4453,14 @@ function toAgentTimelineItem(message) {
|
|
|
4448
4453
|
if (requestKind) {
|
|
4449
4454
|
const payload = asObject2(parseJson(message.content));
|
|
4450
4455
|
if (payload) {
|
|
4451
|
-
|
|
4456
|
+
const item = {
|
|
4452
4457
|
id: message.id,
|
|
4453
|
-
kind: requestKind,
|
|
4454
4458
|
payload,
|
|
4455
4459
|
at: message.createdAt,
|
|
4456
4460
|
...timelineIdentityOf(message),
|
|
4457
4461
|
...parentToolIdOf(message.parentToolId)
|
|
4458
4462
|
};
|
|
4463
|
+
return requestKind === "notification" ? { ...item, kind: requestKind, ...notificationFieldsOf(payload) } : { ...item, kind: requestKind };
|
|
4459
4464
|
}
|
|
4460
4465
|
}
|
|
4461
4466
|
if (message.type === "TOOL_USE") {
|
|
@@ -5472,6 +5477,7 @@ var CoreAgentTaskSession = class {
|
|
|
5472
5477
|
}
|
|
5473
5478
|
repeatsTheRunningTurn(event, lifecycle) {
|
|
5474
5479
|
if (this._status !== "streaming" && this._status !== "cancelled") return false;
|
|
5480
|
+
if (STATE_FRAME_TYPES.has(event.type)) return false;
|
|
5475
5481
|
const turnId = lifecycle?.turnId;
|
|
5476
5482
|
if (typeof turnId !== "string") return false;
|
|
5477
5483
|
if (typeof event.sequence === "number") {
|
|
@@ -5608,15 +5614,17 @@ var CoreAgentTaskSession = class {
|
|
|
5608
5614
|
if (itemId === void 0 && sequence === void 0) return;
|
|
5609
5615
|
this.livePiece(
|
|
5610
5616
|
(item) => item.kind === kind && (itemId !== void 0 ? item.itemId === itemId : item.sequence === sequence),
|
|
5611
|
-
() =>
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5617
|
+
() => {
|
|
5618
|
+
const item = {
|
|
5619
|
+
id: `live:${kind}:${itemId ?? sequence}`,
|
|
5620
|
+
payload,
|
|
5621
|
+
at: liveAtOf(event),
|
|
5622
|
+
...sequence === void 0 ? {} : { sequence },
|
|
5623
|
+
...itemId === void 0 ? {} : { itemId },
|
|
5624
|
+
...parentToolIdOf(parentToolId)
|
|
5625
|
+
};
|
|
5626
|
+
return kind === "notification" ? { ...item, kind, ...notificationFieldsOf(payload) } : { ...item, kind };
|
|
5627
|
+
},
|
|
5620
5628
|
(item) => item
|
|
5621
5629
|
);
|
|
5622
5630
|
}
|