@timefly/opencode-plugin 0.2.1 → 0.2.2
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.map +1 -1
- package/dist/index.js +23 -10
- package/dist/read-chat-params.d.ts +31 -0
- package/dist/read-chat-params.d.ts.map +1 -0
- package/dist/read-chat-params.js +10 -0
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAWjD,eAAO,MAAM,qBAAqB,EAAE,MAyDnC,CAAA;AAED,eAAe,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,25 +2,38 @@ import { createEventTracker } from './event-tracker.js';
|
|
|
2
2
|
import { handleBusEvent } from './event-handlers.js';
|
|
3
3
|
import { mapCompactionInput, mapLlmRequestInput, mapToolCallInput, mapToolResultInput } from './map-opencode-event.js';
|
|
4
4
|
import { createEventPublisher } from './publish-events.js';
|
|
5
|
+
import { resolveChatParams } from './read-chat-params.js';
|
|
5
6
|
import packageJson from '../package.json' with { type: 'json' };
|
|
6
7
|
const PLUGIN_VERSION = packageJson.version;
|
|
7
8
|
export const timeflyOpenCodePlugin = ({ client }) => {
|
|
8
9
|
const tracker = createEventTracker();
|
|
9
10
|
const publisher = createEventPublisher(client, PLUGIN_VERSION);
|
|
10
|
-
return
|
|
11
|
+
return client.app
|
|
12
|
+
.log({
|
|
13
|
+
body: {
|
|
14
|
+
service: 'timefly-opencode-plugin',
|
|
15
|
+
level: 'info',
|
|
16
|
+
message: `TimeFly telemetry active (v${PLUGIN_VERSION})`,
|
|
17
|
+
extra: { source: 'opencode' }
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.then(() => undefined)
|
|
21
|
+
.catch(() => undefined)
|
|
22
|
+
.then(() => Promise.resolve({
|
|
11
23
|
event: (input) => handleBusEvent(input.event, tracker, publisher.publish),
|
|
12
24
|
'chat.params': (input, output) => {
|
|
13
25
|
tracker.recordSessionStats(input.sessionID, { requestCount: 1 });
|
|
26
|
+
const resolvedParams = resolveChatParams(input, output);
|
|
14
27
|
return publisher.publish([
|
|
15
28
|
mapLlmRequestInput({
|
|
16
|
-
sessionID:
|
|
17
|
-
agent:
|
|
18
|
-
providerId:
|
|
19
|
-
modelId:
|
|
20
|
-
providerSource:
|
|
21
|
-
temperature:
|
|
22
|
-
topP:
|
|
23
|
-
maxOutputTokens:
|
|
29
|
+
sessionID: resolvedParams.sessionID,
|
|
30
|
+
agent: resolvedParams.agent,
|
|
31
|
+
providerId: resolvedParams.providerId,
|
|
32
|
+
modelId: resolvedParams.modelId,
|
|
33
|
+
providerSource: resolvedParams.providerSource,
|
|
34
|
+
temperature: resolvedParams.temperature,
|
|
35
|
+
topP: resolvedParams.topP,
|
|
36
|
+
maxOutputTokens: resolvedParams.maxOutputTokens
|
|
24
37
|
})
|
|
25
38
|
]);
|
|
26
39
|
},
|
|
@@ -38,6 +51,6 @@ export const timeflyOpenCodePlugin = ({ client }) => {
|
|
|
38
51
|
})
|
|
39
52
|
]),
|
|
40
53
|
'experimental.session.compacting': (input) => publisher.publish([mapCompactionInput(input.sessionID)])
|
|
41
|
-
});
|
|
54
|
+
}));
|
|
42
55
|
};
|
|
43
56
|
export default timeflyOpenCodePlugin;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ChatParamsInput = {
|
|
2
|
+
sessionID: string;
|
|
3
|
+
agent: string;
|
|
4
|
+
model?: {
|
|
5
|
+
id?: string;
|
|
6
|
+
providerID?: string;
|
|
7
|
+
};
|
|
8
|
+
provider?: {
|
|
9
|
+
source?: string;
|
|
10
|
+
info?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type ChatParamsOutput = {
|
|
16
|
+
temperature: number;
|
|
17
|
+
topP: number;
|
|
18
|
+
maxOutputTokens?: number;
|
|
19
|
+
};
|
|
20
|
+
export type ResolvedChatParams = {
|
|
21
|
+
sessionID: string;
|
|
22
|
+
agent: string;
|
|
23
|
+
providerId: string;
|
|
24
|
+
modelId: string;
|
|
25
|
+
providerSource: string;
|
|
26
|
+
temperature: number;
|
|
27
|
+
topP: number;
|
|
28
|
+
maxOutputTokens?: number;
|
|
29
|
+
};
|
|
30
|
+
export declare const resolveChatParams: (input: ChatParamsInput, output: ChatParamsOutput) => ResolvedChatParams;
|
|
31
|
+
//# sourceMappingURL=read-chat-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-chat-params.d.ts","sourceRoot":"","sources":["../src/read-chat-params.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE;QACP,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,UAAU,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,QAAQ,CAAC,EAAE;QACV,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,IAAI,CAAC,EAAE;YACN,EAAE,CAAC,EAAE,MAAM,CAAA;SACX,CAAA;KACD,CAAA;CACD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,OAAO,eAAe,EAAE,QAAQ,gBAAgB,KAAG,kBASnF,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const resolveChatParams = (input, output) => ({
|
|
2
|
+
sessionID: input.sessionID,
|
|
3
|
+
agent: input.agent,
|
|
4
|
+
providerId: input.provider?.info?.id ?? input.model?.providerID ?? 'unknown',
|
|
5
|
+
modelId: input.model?.id ?? 'unknown',
|
|
6
|
+
providerSource: input.provider?.source ?? 'unknown',
|
|
7
|
+
temperature: output.temperature,
|
|
8
|
+
topP: output.topP,
|
|
9
|
+
maxOutputTokens: output.maxOutputTokens
|
|
10
|
+
});
|