@rine-kit/pubg-plugin 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/index.d.ts +20 -0
- package/dist/index.js +27 -3
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Plugin } from '@rine-kit/plugin-sdk';
|
|
2
2
|
import type { PubgDomainService } from '@rine-kit/pubg-domain';
|
|
3
|
+
import { type ReplyGuideProvider, type ShareAppender } from '@rine-kit/pubg-reply';
|
|
3
4
|
import { type PubgSubjectHost } from '@rine-kit/pubg-tools';
|
|
4
5
|
/** What the host decides for one request from its trusted context. */
|
|
5
6
|
export interface PubgAccess {
|
|
@@ -9,10 +10,29 @@ export interface PubgAccess {
|
|
|
9
10
|
host: PubgSubjectHost;
|
|
10
11
|
/** Names the conversation so result sets stay private to it. */
|
|
11
12
|
sessionId: string;
|
|
13
|
+
/** IANA zone the answers are written in ("today" and clock times). Default Asia/Shanghai, as in Lab. */
|
|
14
|
+
timezone?: string;
|
|
15
|
+
/** The share step for one tool's answer; absent, or returning undefined = no link (the answer then has no ๐ line). */
|
|
16
|
+
share?(toolName: string): ShareAppender | undefined;
|
|
17
|
+
/** Runs after a result was built, e.g. to store the share that was just issued before the link is shown. */
|
|
18
|
+
afterReply?(): Promise<void>;
|
|
12
19
|
}
|
|
13
20
|
export interface PubgPluginOptions<Ctx> {
|
|
14
21
|
/** May look the team up (a database read); the tools wait for it. */
|
|
15
22
|
access(ctx: Ctx): PubgAccess | Promise<PubgAccess>;
|
|
23
|
+
/**
|
|
24
|
+
* Deliver results the way Lab does: every tool result carries the validated `presentation`, the chat-layout
|
|
25
|
+
* `displayText` and the `replyGuide` (and `replyLink` when a share link was issued) instead of the bare Domain
|
|
26
|
+
* envelope. Without it the plugin returns the envelope as before.
|
|
27
|
+
*/
|
|
28
|
+
reply?: {
|
|
29
|
+
/** Worked examples / voice of the reply guide for this request; default is Lab's (Kurisu). */
|
|
30
|
+
guide?(ctx: Ctx): ReplyGuideProvider | undefined;
|
|
31
|
+
/** What the member asked in this turn, so a bare record request ("ไปๆฅๆ็ปฉ") is forced to the whole team. */
|
|
32
|
+
request?(ctx: Ctx): string | undefined;
|
|
33
|
+
};
|
|
34
|
+
/** 'chat' puts Lab's full PUBG skill rules into the instructions (instead of the four-sentence summary). */
|
|
35
|
+
rules?: 'chat' | 'summary';
|
|
16
36
|
}
|
|
17
37
|
/**
|
|
18
38
|
* The PUBG tool catalogue (shared with every other host) as a plugin. The tools take whatever the model
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { definePlugin } from '@rine-kit/plugin-sdk';
|
|
2
|
+
import { forceTeamScope, isBareRecordRequest, jsonToolResult, pubgChatRules, } from '@rine-kit/pubg-reply';
|
|
2
3
|
import { PUBG_TOOLS, runPubgTool } from '@rine-kit/pubg-tools';
|
|
3
|
-
const INSTRUCTIONS =
|
|
4
|
+
const INSTRUCTIONS = [
|
|
5
|
+
"You can look up PUBG statistics and match reviews with the pubg_* tools. Every number, match, player, time range and coverage statement in your answer must come from this turn's tool results; never answer PUBG facts from memory or from the chat. Keep the tool's coverage, data time and partial/unknown states in your answer, and say plainly when data is missing. Name players only by the in-game names or aliases in tool results. Never pass tenant, team or user identifiers: who is asking is decided by the system.",
|
|
6
|
+
'Every new PUBG factual request must call a pubg_* tool in the current turn, even if the chat or an earlier tool result already holds an answer; earlier turns may only resolve who, which period and which scope, never numbers. A repeated or teasing re-ask calls the tool again. Leave refresh out (the default fetches the newest matches first); use refresh: false only when the person explicitly asks for cached data.',
|
|
7
|
+
'A first-person request ("me", "my record") is the asker\'s own account and must never become team: true. A record request that names no one ("yesterday\'s record") is a whole-team request: team: true.',
|
|
8
|
+
'Record requests (today / yesterday / this week) use pubg_query_stats (report, grouped by player), never pubg_search_matches; a per-match list is only for an explicit "which games" ask or as the first step of a review. "The latest / last match" = pubg_search_matches with sort desc, recentN 1, refresh true, then pubg_get_review_facts with the returned matchId. A period review = pubg_search_matches with a relative_period selector (today / yesterday), refresh true, sort asc, pageSize 50, then pubg_get_period_review with the returned resultSetId. Friendly fire / teammate actions in a period = pubg_query_team_damage directly.',
|
|
9
|
+
].join('\n');
|
|
4
10
|
/**
|
|
5
11
|
* The PUBG tool catalogue (shared with every other host) as a plugin. The tools take whatever the model
|
|
6
12
|
* writes after the shared validation, but the Domain service and the meaning of "me" come from the host.
|
|
@@ -12,13 +18,31 @@ export function createPubgPlugin(options) {
|
|
|
12
18
|
input: spec.input,
|
|
13
19
|
run: async (input, ctx, { signal }) => {
|
|
14
20
|
const access = await options.access(ctx);
|
|
15
|
-
|
|
21
|
+
let arguments_ = input;
|
|
22
|
+
if (options.reply?.request && spec.name === 'pubg_query_stats') {
|
|
23
|
+
// A bare record request names no one, so it is the whole team: drop any person the model carried over.
|
|
24
|
+
const scoped = isBareRecordRequest(options.reply.request(ctx))
|
|
25
|
+
? forceTeamScope((input ?? {}))
|
|
26
|
+
: undefined;
|
|
27
|
+
if (scoped)
|
|
28
|
+
arguments_ = scoped;
|
|
29
|
+
}
|
|
30
|
+
const envelope = await runPubgTool(spec, arguments_, {
|
|
16
31
|
service: access.service,
|
|
17
32
|
host: access.host,
|
|
18
33
|
sessionId: access.sessionId,
|
|
19
34
|
...(signal ? { signal } : {}),
|
|
20
35
|
});
|
|
36
|
+
if (!options.reply)
|
|
37
|
+
return envelope;
|
|
38
|
+
const reply = jsonToolResult(spec.name, envelope, access.timezone ?? 'Asia/Shanghai', access.share?.(spec.name), options.reply.guide?.(ctx));
|
|
39
|
+
await access.afterReply?.();
|
|
40
|
+
return reply;
|
|
21
41
|
},
|
|
22
42
|
}));
|
|
23
|
-
return definePlugin({
|
|
43
|
+
return definePlugin({
|
|
44
|
+
id: 'rine.pubg',
|
|
45
|
+
instructions: options.rules === 'chat' ? pubgChatRules() : INSTRUCTIONS,
|
|
46
|
+
tools,
|
|
47
|
+
});
|
|
24
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rine-kit/pubg-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The PUBG tools as an @rine-kit/plugin-sdk plugin (Vercel AI SDK hosts such as RINE). The OpenClaw host keeps its own thin adapter over the same @rine-kit/pubg-tools catalogue.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@rine-kit/plugin-sdk": "0.1.
|
|
16
|
-
"@rine-kit/pubg-
|
|
17
|
-
"@rine-kit/pubg-
|
|
15
|
+
"@rine-kit/plugin-sdk": "0.1.3",
|
|
16
|
+
"@rine-kit/pubg-domain": "0.1.3",
|
|
17
|
+
"@rine-kit/pubg-reply": "0.1.3",
|
|
18
|
+
"@rine-kit/pubg-tools": "0.1.3"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@types/node": "^26.6.5",
|