@datalayer/agent-runtimes 1.3.50 → 1.3.52
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.
|
@@ -32,8 +32,19 @@ export declare function ruleInWords(rule: AppRuleSpec): {
|
|
|
32
32
|
says: string;
|
|
33
33
|
means: string;
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* The rule or Gate an approval was asked under, as the runtime wrote it in
|
|
37
|
+
* its arguments: `_rule` for a rule, `_check` for a Gate (LOOP U-19).
|
|
38
|
+
*/
|
|
36
39
|
export declare const ruleOfApproval: (approval: ApprovalRecord) => string;
|
|
40
|
+
/**
|
|
41
|
+
* The approvals of one application: those its agent asked under its id, and
|
|
42
|
+
* those the runtime marked as its own (`_app`) — a deployment's agent, a
|
|
43
|
+
* Gate's, or a review its drift asked (LOOP U-19). Answered anywhere, an
|
|
44
|
+
* approval leaves every list at once: each decision is broadcast to all the
|
|
45
|
+
* person's pages over the same `/ws`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function approvalsOfApp(approvals: ApprovalRecord[], appId: string): ApprovalRecord[];
|
|
37
48
|
export declare function AppRulesCard({ app }: {
|
|
38
49
|
app: AppSpec;
|
|
39
50
|
}): JSX.Element;
|
|
@@ -27,15 +27,30 @@ export function ruleInWords(rule) {
|
|
|
27
27
|
means: words.means,
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The rule or Gate an approval was asked under, as the runtime wrote it in
|
|
32
|
+
* its arguments: `_rule` for a rule, `_check` for a Gate (LOOP U-19).
|
|
33
|
+
*/
|
|
34
|
+
export const ruleOfApproval = (approval) => {
|
|
35
|
+
const said = approval.tool_args?._rule ?? approval.tool_args?._check;
|
|
36
|
+
return typeof said === 'string' ? said : '';
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The approvals of one application: those its agent asked under its id, and
|
|
40
|
+
* those the runtime marked as its own (`_app`) — a deployment's agent, a
|
|
41
|
+
* Gate's, or a review its drift asked (LOOP U-19). Answered anywhere, an
|
|
42
|
+
* approval leaves every list at once: each decision is broadcast to all the
|
|
43
|
+
* person's pages over the same `/ws`.
|
|
44
|
+
*/
|
|
45
|
+
export function approvalsOfApp(approvals, appId) {
|
|
46
|
+
return approvals.filter(approval => approval.agent_id === appId || approval.tool_args?._app === appId);
|
|
47
|
+
}
|
|
48
|
+
const PENDING = { status: 'pending' };
|
|
32
49
|
function Approvals({ app }) {
|
|
33
|
-
|
|
34
|
-
const filters = useMemo(() => ({ agentId: app.id, status: 'pending' }), [app.id]);
|
|
35
|
-
const query = useToolApprovalsQuery(filters);
|
|
50
|
+
const query = useToolApprovalsQuery(PENDING);
|
|
36
51
|
const approve = useApproveToolRequest();
|
|
37
52
|
const reject = useRejectToolRequest();
|
|
38
|
-
const waiting = query.data?.approvals ?? [];
|
|
53
|
+
const waiting = useMemo(() => approvalsOfApp(query.data?.approvals ?? [], app.id), [query.data, app.id]);
|
|
39
54
|
return (_jsxs(Box, { "data-testid": "app-approvals", children: [_jsx(Heading, { as: "h4", sx: { fontSize: 1, mt: 3, mb: 1 }, children: APP_RULES_WORDS.waiting }), approve.connectionState !== 'connected' ? (_jsx(Text, { as: "p", sx: { fontSize: 0, color: 'fg.muted', m: 0, mb: 1 }, children: APP_RULES_WORDS.offline })) : null, waiting.length === 0 ? (_jsx(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted', m: 0 }, children: APP_RULES_WORDS.nothingWaiting })) : (_jsx(Box, { as: "ul", sx: { listStyle: 'none', p: 0, m: 0 }, children: waiting.map(approval => (_jsxs(Box, { as: "li", sx: {
|
|
40
55
|
py: 2,
|
|
41
56
|
borderTop: '1px solid',
|
|
@@ -3,5 +3,5 @@ import type { AppSpec } from '../../../types/agentspecs';
|
|
|
3
3
|
export declare const APP_RULES_PLUGIN_NAME = "@datalayer/loop-plugin-app-rules";
|
|
4
4
|
/** The plugin that lists an application's rules and the approvals waiting for the person. */
|
|
5
5
|
export declare function defineAppRulesPlugin(app: AppSpec): ReactorPlugin<Record<string, never>, unknown, unknown>;
|
|
6
|
-
export { AppRulesCard, APP_RULES_WORDS, ruleInWords, ruleOfApproval, } from './AppRulesCard';
|
|
6
|
+
export { AppRulesCard, APP_RULES_WORDS, ruleInWords, ruleOfApproval, approvalsOfApp, } from './AppRulesCard';
|
|
7
7
|
export default defineAppRulesPlugin;
|
|
@@ -27,5 +27,5 @@ export function defineAppRulesPlugin(app) {
|
|
|
27
27
|
});
|
|
28
28
|
return plugin;
|
|
29
29
|
}
|
|
30
|
-
export { AppRulesCard, APP_RULES_WORDS, ruleInWords, ruleOfApproval, } from './AppRulesCard';
|
|
30
|
+
export { AppRulesCard, APP_RULES_WORDS, ruleInWords, ruleOfApproval, approvalsOfApp, } from './AppRulesCard';
|
|
31
31
|
export default defineAppRulesPlugin;
|