@piagent/platform 1.49.0 → 1.49.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/CHANGELOG.md +16 -0
- package/docs/command-reference-vietnamese.md +2 -2
- package/docs/distribution-standard.md +6 -6
- package/docs/harness-conformance.md +3 -3
- package/docs/operator-manual-vietnamese.md +7 -7
- package/docs/publishing-for-teams.md +1 -0
- package/docs/release-install-policy.md +2 -2
- package/docs/team-onboarding.md +2 -2
- package/docs-site/architecture.html +1 -1
- package/docs-site/assets/search-en.json +1 -1
- package/docs-site/assets/search-vi.json +1 -1
- package/docs-site/benchmark.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/context-engine.html +1 -1
- package/docs-site/ecosystem.html +1 -1
- package/docs-site/en/architecture.html +1 -1
- package/docs-site/en/benchmark.html +1 -1
- package/docs-site/en/commands.html +1 -1
- package/docs-site/en/context-engine.html +1 -1
- package/docs-site/en/ecosystem.html +1 -1
- package/docs-site/en/index.html +9 -9
- package/docs-site/en/mcp-approval.html +1 -1
- package/docs-site/en/mcp-auth.html +1 -1
- package/docs-site/en/mcp-servers.html +1 -1
- package/docs-site/en/mcp.html +1 -1
- package/docs-site/en/permissions.html +1 -1
- package/docs-site/en/profiles.html +1 -1
- package/docs-site/en/quickstart.html +1 -1
- package/docs-site/en/runtime.html +1 -1
- package/docs-site/en/scope.html +1 -1
- package/docs-site/en/security.html +1 -1
- package/docs-site/en/team.html +1 -1
- package/docs-site/en/update.html +3 -3
- package/docs-site/en/whats-new.html +30 -16
- package/docs-site/en/windows.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +9 -9
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/releases.json +46 -0
- package/docs-site/runtime.html +1 -1
- package/docs-site/scope.html +1 -1
- package/docs-site/security.html +1 -1
- package/docs-site/team.html +1 -1
- package/docs-site/update.html +3 -3
- package/docs-site/whats-new.html +30 -16
- package/docs-site/windows.html +1 -1
- package/docs-site/workflows.html +1 -1
- package/evals/private-holdout-v1/public-exposure.v2.json +2 -2
- package/package.json +1 -1
- package/packages/piagent-core/managed/fast-mode.mjs +19 -16
- package/packages/piagent-core/managed/helper-run.mjs +19 -2
- package/packages/piagent-core/managed/request-stream.mjs +2 -2
- package/packages/piagent-core/managed/session.mjs +2 -2
- package/packages/piagent-core/managed/workflow.mjs +3 -0
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-webui/dist/client/assets/ActivityPanel-CmjxPmNT.js +1 -0
- package/packages/piagent-webui/dist/client/assets/{App-CU-wndsb.js → App-JrRb7jgn.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/GatewayApp-BmkqeXih.js +63 -0
- package/packages/piagent-webui/dist/client/assets/{InspectionApp-Bfvr2S8S.js → InspectionApp-9jBsgkVJ.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionAgentWorkspace-0Xowe-sG.js → SessionAgentWorkspace-RQ0N65d9.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionInspectorDrawer-72Z5908P.js → SessionInspectorDrawer-BWyEN4bf.js} +2 -2
- package/packages/piagent-webui/dist/client/assets/{SettingsNavigation-Bu1A7x4F.js → SettingsNavigation-Wx-q5QQk.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SettingsPage-DxGxE0AF.js → SettingsPage-xAt6kSyZ.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{TerminalPanel-BKgx9SjR.js → TerminalPanel-DzHdSjpN.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceCodeEditor-DFrh3qs2.js → WorkspaceCodeEditor-CEuPTTBd.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceExplorer-D6ufO-eP.js → WorkspaceExplorer-B_NwYf4S.js} +3 -3
- package/packages/piagent-webui/dist/client/assets/{index-CjM70M7D.css → index-De7bIeMc.css} +1 -1
- package/packages/piagent-webui/dist/client/assets/{index-C3CJv1wM.js → index-fUpioGMZ.js} +2 -2
- package/packages/piagent-webui/dist/client/index.html +2 -2
- package/packages/piagent-webui/gateway/gateway-session-stream.ts +28 -0
- package/packages/piagent-webui/gateway/managed-projection.ts +8 -1
- package/packages/piagent-webui/gateway/session-catalog.ts +2 -2
- package/packages/piagent-webui/server/tool-call-summary.ts +13 -0
- package/packages/piagent-webui/server/transcript-projection.ts +11 -4
- package/schemas/piagent-webui/gateway-protocol-v1.schema.json +2 -0
- package/schemas/piagent-webui/session-catalog-v1.schema.json +1 -1
- package/schemas/piagent-webui/transcript-v1.schema.json +17 -1
- package/scripts/company-terminal.mjs +2 -2
- package/packages/piagent-webui/dist/client/assets/ActivityPanel-Bv-jc1s3.js +0 -1
- package/packages/piagent-webui/dist/client/assets/GatewayApp-MIvgr7kn.js +0 -63
|
@@ -256,8 +256,8 @@
|
|
|
256
256
|
},
|
|
257
257
|
{
|
|
258
258
|
"path": "tests",
|
|
259
|
-
"fileCount":
|
|
260
|
-
"sha256": "
|
|
259
|
+
"fileCount": 648,
|
|
260
|
+
"sha256": "c71a827c77f6d8a2557cc956bd7cc4b9d1863c81503b584784f130fe466932e7"
|
|
261
261
|
}
|
|
262
262
|
],
|
|
263
263
|
"custodianComparisonRules": {
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// Fast mode of a company conversation. The member turns it on per
|
|
2
2
|
// conversation, and only where the team's Harness in Studio allows it
|
|
3
3
|
// (harness.configuration.fast_mode); a conversation starts with it off. While
|
|
4
|
-
// on, the main agent's
|
|
5
|
-
// the
|
|
6
|
-
//
|
|
7
|
-
//
|
|
4
|
+
// on, every call of the conversation, the main agent's and its subagents', asks
|
|
5
|
+
// for the priority service tier where its model serves it: the same model and
|
|
6
|
+
// thinking level, answered faster, and charged to the key's quota at a higher
|
|
7
|
+
// rate (Studio decides the rate and refuses the tier for a run whose Harness
|
|
8
|
+
// does not allow it). A model that does not serve it runs at standard speed,
|
|
9
|
+
// so a Claude main agent with Codex subagents still gets it on the subagents.
|
|
8
10
|
const ENTRY = 'agent-watch-fast';
|
|
9
11
|
export const NOTICE = 'agent-watch-fast-notice';
|
|
10
12
|
export const FAST_SERVICE_TIER = 'priority';
|
|
@@ -27,7 +29,7 @@ export function fastSetter(owner, manager) {
|
|
|
27
29
|
return enabled => {
|
|
28
30
|
if (enabled && !fastAllowed(owner.manifest)) throw Error('managed-fast-unavailable');
|
|
29
31
|
if (Boolean(enabled) === Boolean(owner.fast)) return false;
|
|
30
|
-
owner.fast = Boolean(enabled); manager.appendCustomEntry(ENTRY, { enabled: owner.fast, allowed: fastAllowed(owner.manifest), at: new Date().toISOString() });
|
|
32
|
+
owner.fast = Boolean(enabled); owner.fastDeclined?.clear(); manager.appendCustomEntry(ENTRY, { enabled: owner.fast, allowed: fastAllowed(owner.manifest), at: new Date().toISOString() });
|
|
31
33
|
return true;
|
|
32
34
|
};
|
|
33
35
|
}
|
|
@@ -44,21 +46,22 @@ export const fastServed = route => route?.provider === 'codex' && CODEX_FAST.has
|
|
|
44
46
|
// Studio's refusal of the tier (the Harness or the model list changed), or
|
|
45
47
|
// the provider's of a request carrying it: asked again once without it.
|
|
46
48
|
export const fastRefusal = code => code === 'policy_denied' || code === 'upstream_request_rejected';
|
|
47
|
-
// A fast request was refused before the model did any work:
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// A fast request was refused before the model did any work: that model goes
|
|
50
|
+
// back to standard speed and the others keep fast mode. Only the main agent's
|
|
51
|
+
// model says so; turning Fast off and on asks again.
|
|
52
|
+
export function declineFast(owner, code, role = 'main', route = null) {
|
|
53
|
+
(owner.fastDeclined ??= new Set()).add(route?.native ?? '');
|
|
54
|
+
if (role !== 'main') return;
|
|
51
55
|
try {
|
|
52
|
-
recordFast(owner, owner.session.sessionManager);
|
|
53
56
|
void owner.session.sendCustomMessage?.({ customType: NOTICE, display: true, details: { code },
|
|
54
|
-
content: `Fast mode was refused for this
|
|
57
|
+
content: `Fast mode was refused for this model [${code}]: its calls continue at standard speed. Turn Fast off and on again to retry.` }, { triggerTurn: false })?.catch?.(() => {});
|
|
55
58
|
} catch { /* the request goes on at standard speed either way */ }
|
|
56
59
|
}
|
|
57
|
-
// The payload hook of one request:
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
export function fastPayload(owner,
|
|
61
|
-
if (
|
|
60
|
+
// The payload hook of one request: a call on a model that serves fast mode
|
|
61
|
+
// carries the tier while fast mode is on and still allowed (the Harness may
|
|
62
|
+
// have turned it off since the member turned it on).
|
|
63
|
+
export function fastPayload(owner, route, onPayload) {
|
|
64
|
+
if (!owner.fast || !fastAllowed(owner.manifest) || !fastServed(route) || owner.fastDeclined?.has(route.native)) return onPayload;
|
|
62
65
|
return async (payload, model) => {
|
|
63
66
|
const next = (onPayload ? await onPayload(payload, model) : undefined) ?? payload;
|
|
64
67
|
return next && typeof next === 'object' && !Array.isArray(next) ? { ...next, service_tier: FAST_SERVICE_TIER } : next;
|
|
@@ -201,7 +201,7 @@ async function answerUnder(managed, key, task, signal, harness, snapshot, parts,
|
|
|
201
201
|
for (const session of sessions) session.dispose(); await boundary?.dispose();
|
|
202
202
|
await settleHelper(managed, renew.lease, report); // with the role's current token, before it closes
|
|
203
203
|
await closeRole(managed, key);
|
|
204
|
-
for (const who of watched) helperState(managed, who, null);
|
|
204
|
+
for (const who of watched) { helperState(managed, who, null); saveHelperSteps(managed, who); }
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -216,12 +216,29 @@ export function helperState(managed, key, state) {
|
|
|
216
216
|
// latest tool step, told to listeners as it changes (company-terminal.mjs).
|
|
217
217
|
function watchHelper(managed, key, session, task, title) {
|
|
218
218
|
const job = String(title || task.split('\n').find(line => line.trim()) || '').trim().slice(0, 120);
|
|
219
|
+
const logs = managed.helperLogs ??= new Map();
|
|
220
|
+
const log = logs.get(key) ?? { job, startedAt: new Date().toISOString(), total: 0, steps: [] }; logs.set(key, log);
|
|
219
221
|
helperState(managed, key, { job, step: 'đọc brief' });
|
|
220
222
|
session.subscribe?.(event => {
|
|
221
223
|
if (event?.type !== 'tool_execution_start') return;
|
|
222
|
-
|
|
224
|
+
const args = stepArgs(event.args);
|
|
225
|
+
log.total += 1; log.steps.push({ tool: String(event.toolName), args, at: new Date().toISOString() }); log.steps.splice(0, log.steps.length - HELPER_STEPS_KEPT);
|
|
226
|
+
helperState(managed, key, { job, step: stepText(event.toolName, event.args), tool: String(event.toolName), args });
|
|
223
227
|
});
|
|
224
228
|
}
|
|
229
|
+
// A helper's session lives in memory: what it called is kept here so the
|
|
230
|
+
// dashboard's Activity can still show it once the helper has ended.
|
|
231
|
+
const HELPER_STEPS_KEPT = 200;
|
|
232
|
+
function saveHelperSteps(managed, key) {
|
|
233
|
+
const log = managed.helperLogs?.get(key); if (!log) return;
|
|
234
|
+
managed.helperLogs.delete(key);
|
|
235
|
+
managed.session?.sessionManager?.appendCustomEntry?.('agent-watch-helper-steps', { agent: key, ...log, endedAt: new Date().toISOString() });
|
|
236
|
+
}
|
|
237
|
+
function stepArgs(args = {}) {
|
|
238
|
+
const out = {};
|
|
239
|
+
for (const name of ['path', 'pattern', 'command', 'query', 'url']) if (typeof args?.[name] === 'string') out[name] = args[name].slice(0, 300);
|
|
240
|
+
return out;
|
|
241
|
+
}
|
|
225
242
|
const STEP = { read: 'đọc', grep: 'tìm', find: 'tìm file', ls: 'xem thư mục', bash: 'chạy', web_search: 'tìm trên web', web_fetch: 'đọc trang', memory_search: 'tra team memory', memory_ask: 'hỏi team memory' };
|
|
226
243
|
export function stepText(tool, args = {}) {
|
|
227
244
|
const what = args?.path ?? args?.pattern ?? args?.command ?? args?.query ?? args?.url ?? '';
|
|
@@ -92,7 +92,7 @@ export function wrapRoleStreams(owner, runtime, role, { provider, verifyGrant })
|
|
|
92
92
|
// same company account and prompt cache; a helper names its role.
|
|
93
93
|
const conversation = role === 'main' ? conversationSession(owner) : null;
|
|
94
94
|
// Fast mode, where the member turned it on and the model serves it (fast-mode.mjs).
|
|
95
|
-
const onPayload = fastPayload(owner,
|
|
95
|
+
const onPayload = fastPayload(owner, route, options?.onPayload), fast = onPayload !== options?.onPayload;
|
|
96
96
|
// Studio's id for this request, from its answer's headers: a
|
|
97
97
|
// stream that ends here without an answer is ended there too.
|
|
98
98
|
let studioRequest = null;
|
|
@@ -118,7 +118,7 @@ export function wrapRoleStreams(owner, runtime, role, { provider, verifyGrant })
|
|
|
118
118
|
out.end(told(result)); return;
|
|
119
119
|
}
|
|
120
120
|
// Refused with the fast tier: asked again at standard speed.
|
|
121
|
-
if (fast && fastRefusal(failureCode(refusal.errorMessage))) { letGo(); declineFast(owner, failureCode(refusal.errorMessage)); continue; }
|
|
121
|
+
if (fast && fastRefusal(failureCode(refusal.errorMessage))) { letGo(); declineFast(owner, failureCode(refusal.errorMessage), role, route); continue; }
|
|
122
122
|
refused = String(refusal.errorMessage ?? '');
|
|
123
123
|
// A lapsed or replaced grant: the next ask renews it, not this share.
|
|
124
124
|
const stale = share; letGo();
|
|
@@ -482,10 +482,10 @@ export class ManagedSession {
|
|
|
482
482
|
publishHelpers() {
|
|
483
483
|
// One of each enabled helper role can run at a time.
|
|
484
484
|
const maximum = helperRoles(this.manifest).length;
|
|
485
|
-
this.session.sessionManager.appendCustomEntry('agent-watch-helpers', {active:this.helpers.size,maximum});
|
|
485
|
+
this.session.sessionManager.appendCustomEntry('agent-watch-helpers', {active:this.helpers.size,maximum,roles:[...this.helpers.keys()]});
|
|
486
486
|
// A helper runs while the main agent is quiet: listeners (the WebUI's
|
|
487
487
|
// "1/4 running") are told, since no agent event would say so.
|
|
488
|
-
this.notify({ type: 'managed_helpers', active: this.helpers.size, maximum });
|
|
488
|
+
this.notify({ type: 'managed_helpers', active: this.helpers.size, maximum, roles: [...this.helpers.keys()] });
|
|
489
489
|
}
|
|
490
490
|
notify(event) {
|
|
491
491
|
for (const listener of [...this.listeners]) { try { listener(event); } catch { /* a listener's failure is its own */ } }
|
|
@@ -314,6 +314,9 @@ export async function completionGate(managed, run, signal) {
|
|
|
314
314
|
const focus = run.sentAt !== null ? await reviewFocus(managed) : null, previous = (review?.findings ?? []).filter(f => f.severity === 'blocking').map((f, i) => `${i + 1}. ${findingText(f)}`).join('\n');
|
|
315
315
|
const brief = `Review the current patch against the member's request.\n\nChecks: ${run.partOnlyOn(digest) ? 'only part of the test suite passed on this code' : run.verified ? 'a repository check passed on this code' : 'no check has passed on this code'}.${answer ? `\n\nThe main agent's answer to your previous blocking findings (the code changed after it):\n${answer}` : ''}${focus ? `\n\nSince your last review only these files changed: ${focus.files.join(', ')}. Judge whether each previous blocking finding is fixed (repeat it when it is not) and review the changes in these files; the rest of the patch was reviewed and has not changed.${previous ? `\nYour previous blocking findings:\n${previous}` : ''}` : ''}`;
|
|
316
316
|
managed.reviewFocus = focus;
|
|
317
|
+
// The answer so far is not the result yet: the dashboard marks it so.
|
|
318
|
+
// An entry, not a message: the model has nothing to do with it.
|
|
319
|
+
session.sessionManager.appendCustomEntry('agent-watch-review-start', {});
|
|
317
320
|
try { await managed.delegate({ role: 'review', task: brief }, signal, { harness: true }); }
|
|
318
321
|
catch (error) {
|
|
319
322
|
run.reviewUnavailable = !stopped(); run.reviewUnavailableReason = reviewUnavailableReason(error?.message); interrupted = stopped();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{An as n,Rn as r}from"./vendor-DNZbaWhT.js";import{i,n as a}from"./ui-preferences-OfS30-ZV.js";import{B as o,K as s,x as c}from"./api-BQS4Dtrr.js";import{c as l}from"./view-model-CWNiS4JN.js";var u=t(r(),1);function d(e,t=`vi`){let n=e.state===`running`?`running`:e.state===`failed`?`failed`:`passed`,r=n===`running`?t===`vi`?`đang chạy`:`running`:n===`failed`?t===`vi`?`thất bại`:`failed`:t===`vi`?`hoàn tất`:`completed`,i=e.startedAt??e.finishedAt??``;return{activityRef:`live.${e.toolCallRef}`,kind:[`bash`,`shell`,`exec`].includes(e.toolLabel)?`command`:`tool`,state:n,label:`${e.agent?`${e.agent} · `:``}${e.toolLabel} ${r}`,preview:e.detail??e.fileLabel??(t===`vi`?`Cập nhật trực tiếp từ Gateway`:`Live update from the Gateway`),toolCallId:e.toolCallRef,toolName:e.toolLabel,commandDigest:null,logRef:null,exitCode:null,exitCodeExact:!1,startedAt:i,finishedAt:n===`running`?null:e.finishedAt??i}}function f(e,t=`vi`){let n=e.state===`failed`?t===`vi`?`Lượt chạy gặp lỗi`:`Operation failed`:e.state===`blocked`?t===`vi`?`Lượt chạy bị chặn`:`Operation blocked`:e.state===`aborted`?t===`vi`?`Lượt chạy đã dừng`:`Operation stopped`:t===`vi`?`Chưa xác định kết quả lượt chạy`:`Operation outcome unknown`;return{activityRef:e.activityRef,kind:`system`,state:e.state,label:n,preview:e.reasonCode,toolCallId:null,toolName:null,commandDigest:null,logRef:null,exitCode:null,exitCodeExact:!1,startedAt:e.settledAt,finishedAt:e.settledAt}}function p(e,t,n,r=`vi`,i){let a=[...e,...t],o=new Set(a.map(e=>e.activityRef)),s=n.filter(e=>!o.has(e.activityRef)).map(e=>f(e,r));if(i===void 0)return{rows:[...e,...s,...t],terminalCount:s.length,runningCount:e.length};let c=i.filter(e=>e.state===`running`).map(e=>d(e,r));return{rows:[...c,...s,...t],terminalCount:s.length,runningCount:c.length}}function m(e,t=`vi`){return e.state===`passed`&&/ recovered$/i.test(e.label)?t===`vi`?`Đã khôi phục`:`Recovered`:e.state===`passed`&&/ warning$/i.test(e.label)?t===`vi`?`Đã xử lý cảnh báo`:`Handled warning`:e.state===`passed`&&e.exitCodeExact?`Pass · exit ${e.exitCode??0}`:e.state===`failed`&&e.exitCodeExact?`Fail · exit ${e.exitCode??`?`}`:e.state===`blocked`?`Blocked`:e.state===`aborted`?t===`vi`?`Đã dừng`:`Stopped`:e.state===`unknown`?t===`vi`?`Chưa xác định`:`Unknown`:e.state===`failed`?t===`vi`?`Thất bại`:`Failed`:e.state===`running`?t===`vi`?`Đang chạy`:`Running`:e.state.replaceAll(`-`,` `)}function h(e,t=`vi`){let n=Date.parse(e.startedAt),r=e.finishedAt?Date.parse(e.finishedAt):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return t===`vi`?`Thời gian chưa xác định`:`Unknown duration`;let i=Math.round((r-n)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function g(e,t=[]){let n=new Map([[`main`,{agent:`main`,steps:[],total:0}]]),r=e=>{let t=n.get(e);if(t)return t;let r={agent:e,steps:[],total:0};return n.set(e,r),r};for(let t of e){if(t.helperRun){let e=r(t.helperRun.agent);e.total+=t.helperRun.total,e.steps.push(...t.helperRun.steps.map((e,n)=>({key:`${t.messageRef}:${n}`,toolName:e.toolName,target:e.target,state:`completed`,at:e.at})));continue}if(t.role!==`assistant`)continue;let e=r(`main`);for(let n of t.toolCalls)e.total+=1,e.steps.push({key:`${t.messageRef}:${n.toolCallRef}`,toolName:n.toolName,target:n.summary?.target??n.summary?.detail??null,state:n.state===`failed`||n.result?.isError?`failed`:`completed`,at:t.recordedAt})}for(let e of t){if(!e.agent||e.state===`running`)continue;let t=r(e.agent);t.total+=1,t.steps.push({key:e.toolCallRef,toolName:e.toolLabel,target:e.detail??null,state:e.state,at:e.startedAt??``})}for(let e of n.values())e.steps.sort((e,t)=>t.at.localeCompare(e.at));return[...n.values()].filter(e=>e.steps.length>0)}var _=n();function v(e,t){return e===`main`?a(t,`Main agent`,`Main agent`):`Subagent ${e}`}function y(e,t){let n=new Date(e);return Number.isFinite(n.getTime())?n.toLocaleTimeString(t===`vi`?`vi-VN`:`en-US`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}var b=5e3;function x({sessionRef:e,running:t,live:n,locale:r,empty:i}){let[o,c]=(0,u.useState)([]);(0,u.useEffect)(()=>{let n=new AbortController,r=()=>void s(e,null,200,n.signal).then(e=>c(e.items)).catch(()=>void 0);r();let i=t?window.setInterval(r,b):void 0;return()=>{n.abort(),i&&window.clearInterval(i)}},[e,t]);let d=(0,u.useMemo)(()=>g(o,n),[o,n]);return d.length?(0,_.jsx)(`div`,{className:`agent-activity-log`,children:d.map(e=>(0,_.jsxs)(`details`,{open:e.agent===`main`||t,className:`agent-activity-group`,children:[(0,_.jsxs)(`summary`,{children:[(0,_.jsx)(`strong`,{children:v(e.agent,r)}),` `,(0,_.jsxs)(`span`,{children:[e.total,` `,a(r,`lần gọi`,`calls`)]}),e.total>e.steps.length&&(0,_.jsxs)(`span`,{children:[` · `,a(r,`hiện ${e.steps.length} gần nhất`,`showing the latest ${e.steps.length}`)]})]}),e.steps.map(e=>(0,_.jsxs)(`article`,{className:`activity-row`,children:[(0,_.jsx)(`span`,{className:`activity-state tone-${l(e.state)}`,"aria-label":e.state}),(0,_.jsxs)(`div`,{className:`activity-copy`,children:[(0,_.jsx)(`div`,{children:(0,_.jsx)(`strong`,{children:e.toolName})}),e.target&&(0,_.jsx)(`p`,{children:e.target})]}),(0,_.jsx)(`div`,{className:`activity-result`,children:(0,_.jsx)(`span`,{children:y(e.at,r)})})]},e.key))]},e.agent))}):i?(0,_.jsx)(`div`,{className:`activity-empty`,children:i}):null}var S=e({ActivityPanel:()=>w});function C({activity:e,preview:t,onPreview:n,locale:r}){return(0,_.jsxs)(`article`,{className:`activity-row`,children:[(0,_.jsx)(`span`,{className:`activity-state tone-${l(e.state)}`,"aria-label":e.state}),(0,_.jsxs)(`div`,{className:`activity-copy`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`strong`,{children:e.label}),(0,_.jsx)(`span`,{children:e.kind})]}),(0,_.jsx)(`p`,{children:e.preview||a(r,`Không có mô tả ngắn`,`No short description`)}),t&&(0,_.jsxs)(`div`,{className:`log-preview ${t.state===`error`?`error-state`:``}`,children:[t.state===`loading`?a(r,`Đang tải log ngắn…`,`Loading log preview…`):t.state===`error`?a(r,`Log preview không còn sẵn sàng.`,`Log preview is no longer available.`):t.value?.preview??`${a(r,`Không có nội dung log`,`No log content`)} · ${t.value?.reasonCode??`unavailable`}`,t.value?.truncated&&(0,_.jsx)(`small`,{children:a(r,`Preview đã được rút gọn`,`Preview truncated`)})]})]}),(0,_.jsxs)(`div`,{className:`activity-result`,children:[(0,_.jsx)(`strong`,{children:m(e,r)}),(0,_.jsx)(`span`,{children:h(e,r)}),e.logRef&&n&&(0,_.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":!!t,children:t?a(r,`Ẩn log`,`Hide log`):a(r,`Xem log`,`View log`)})]})]})}function w({snapshot:e,sessionRef:t,terminalActivities:n=[],liveActivities:r}){let{locale:s}=i(),[l,d]=(0,u.useState)({}),f=e?.activity.running??[],m=e?.activity.recent??[],{rows:h,terminalCount:g,runningCount:v}=p(f,m,n,s,r),y=e=>{if(l[e.activityRef]){d(t=>({...t,[e.activityRef]:void 0}));return}d(t=>({...t,[e.activityRef]:{state:`loading`}})),(t?o(t,e.activityRef):c(e.activityRef)).then(t=>d(n=>({...n,[e.activityRef]:{state:`ready`,value:t}}))).catch(()=>d(t=>({...t,[e.activityRef]:{state:`error`}})))};return(0,_.jsxs)(`section`,{className:`activity-panel surface`,"aria-labelledby":`activity-title`,children:[(0,_.jsxs)(`header`,{className:`panel-heading`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`section-kicker`,children:`Activity`}),(0,_.jsx)(`h2`,{id:`activity-title`,children:a(s,`Tool, command và kết quả lượt chạy`,`Tools, commands, and operation outcomes`)})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`span`,{className:`running-count`,children:[v,` `,a(s,`đang chạy`,`running`)]}),(0,_.jsxs)(`span`,{children:[m.length+g,` `,a(s,`gần đây`,`recent`)]})]})]}),(0,_.jsxs)(`div`,{className:`activity-list`,children:[h.map(e=>(0,_.jsx)(C,{activity:e,preview:l[e.activityRef],onPreview:e.logRef?()=>y(e):void 0,locale:s},e.activityRef)),t&&(0,_.jsx)(x,{sessionRef:t,running:!!r,live:r,locale:s,empty:h.length===0?a(s,`Chưa có tool, command hoặc kết quả lượt chạy nào trong timeline hiện tại.`,`No tools, commands, or operation outcomes in the current timeline.`):void 0}),h.length===0&&!t&&(0,_.jsx)(`div`,{className:`activity-empty`,children:a(s,`Chưa có tool, command hoặc kết quả lượt chạy nào trong timeline hiện tại.`,`No tools, commands, or operation outcomes in the current timeline.`)})]}),e?.activity.page.truncated&&(0,_.jsx)(`footer`,{className:`panel-footnote`,children:a(s,`Timeline đã được rút gọn theo giới hạn local.`,`The timeline was truncated to local limits.`)})]})}export{S as n,w as t};
|