@nekro-nxt/contracts 0.3.0 → 0.5.0

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.
Files changed (37) hide show
  1. package/README.md +2 -0
  2. package/dist/index.mjs +2512 -78
  3. package/dist/index.mjs.map +1 -1
  4. package/lib/types/commands.d.ts +408 -0
  5. package/lib/types/commands.d.ts.map +1 -0
  6. package/lib/types/community-feedback-host.d.ts +442 -0
  7. package/lib/types/community-feedback-host.d.ts.map +1 -0
  8. package/lib/types/community-feedback.d.ts +1072 -0
  9. package/lib/types/community-feedback.d.ts.map +1 -0
  10. package/lib/types/community-personas.d.ts +4 -0
  11. package/lib/types/community-personas.d.ts.map +1 -1
  12. package/lib/types/community.d.ts +251 -13
  13. package/lib/types/community.d.ts.map +1 -1
  14. package/lib/types/domain.d.ts +33 -0
  15. package/lib/types/domain.d.ts.map +1 -1
  16. package/lib/types/extension-capabilities.d.ts +105 -3
  17. package/lib/types/extension-capabilities.d.ts.map +1 -1
  18. package/lib/types/extension-ui.d.ts +86 -7
  19. package/lib/types/extension-ui.d.ts.map +1 -1
  20. package/lib/types/host-api.d.ts +11109 -3874
  21. package/lib/types/host-api.d.ts.map +1 -1
  22. package/lib/types/index.d.ts +4 -0
  23. package/lib/types/index.d.ts.map +1 -1
  24. package/lib/types/logs.d.ts +355 -0
  25. package/lib/types/logs.d.ts.map +1 -0
  26. package/package.json +1 -1
  27. package/src/commands.ts +366 -0
  28. package/src/community-feedback-host.ts +121 -0
  29. package/src/community-feedback.ts +289 -0
  30. package/src/community.ts +56 -1
  31. package/src/domain.ts +59 -6
  32. package/src/extension-capabilities.ts +159 -8
  33. package/src/extension-ui.ts +40 -0
  34. package/src/host-api.ts +1540 -67
  35. package/src/index.ts +5 -0
  36. package/src/logs.ts +138 -0
  37. package/src/management-api.ts +1 -1
package/src/index.ts CHANGED
@@ -7,3 +7,8 @@ export * from './runtime-compatibility.js'
7
7
  export * from './extension-capabilities.js'
8
8
  export * from './community.js'
9
9
  export * from './community-personas.js'
10
+
11
+ export * from './commands.js'
12
+ export * from './logs.js'
13
+ export * from './community-feedback.js'
14
+ export * from './community-feedback-host.js'
package/src/logs.ts ADDED
@@ -0,0 +1,138 @@
1
+ import { z } from 'zod'
2
+
3
+ /** Log summaries are labels; leave structured diagnostics and stacks untouched. */
4
+ export function formatLogMessage(message: string): string {
5
+ return message.trimEnd().replace(/[。.]$/u, '')
6
+ }
7
+
8
+ export const hostLogLevelSchema = z.enum(['debug', 'info', 'warn', 'error'])
9
+ export type HostLogLevel = z.infer<typeof hostLogLevelSchema>
10
+ /** Write-only, owner-bound SDK capability. No caller-supplied identity fields. */
11
+ export interface NxtLogger {
12
+ debug(message: string, details?: unknown): void
13
+ info(message: string, details?: unknown): void
14
+ warn(message: string, details?: unknown): void
15
+ error(message: string, details?: unknown): void
16
+ }
17
+ export const hostLogSourceKindSchema = z.enum(['system', 'dsh-plugin', 'extension', 'connection', 'unknown'])
18
+ export type HostLogSourceKind = z.infer<typeof hostLogSourceKindSchema>
19
+ export const hostLogSourceSchema = z
20
+ .object({
21
+ kind: hostLogSourceKindSchema,
22
+ id: z.string().min(1).max(512),
23
+ name: z.string().min(1).max(512),
24
+ version: z.string().max(512).optional(),
25
+ component: z.string().max(512).optional(),
26
+ })
27
+ .strict()
28
+ export type HostLogSource = z.infer<typeof hostLogSourceSchema>
29
+ export const hostLogScopeSchema = z
30
+ .object({
31
+ extensionId: z.string().max(512).optional(),
32
+ revisionId: z.string().max(512).optional(),
33
+ connectionId: z.string().max(512).optional(),
34
+ agentId: z.string().max(512).optional(),
35
+ channelId: z.string().max(512).optional(),
36
+ sessionId: z.string().max(512).optional(),
37
+ episodeId: z.string().max(512).optional(),
38
+ operationId: z.string().max(512).optional(),
39
+ })
40
+ .strict()
41
+ export type HostLogScope = z.infer<typeof hostLogScopeSchema>
42
+ export const hostLogEntrySchema = z
43
+ .object({
44
+ id: z.string(),
45
+ sequence: z.number().int().nonnegative(),
46
+ timestamp: z.iso.datetime(),
47
+ runId: z.string(),
48
+ level: hostLogLevelSchema,
49
+ message: z.string(),
50
+ source: hostLogSourceSchema,
51
+ scope: hostLogScopeSchema.optional(),
52
+ details: z.json().optional(),
53
+ code: z.string().optional(),
54
+ redacted: z.boolean(),
55
+ truncated: z.boolean(),
56
+ })
57
+ .strict()
58
+ export type HostLogEntry = z.infer<typeof hostLogEntrySchema>
59
+ export interface HostLogInput {
60
+ formatArgs?: readonly unknown[]
61
+ level: HostLogLevel
62
+ message: string
63
+ source: HostLogSource
64
+ scope?: HostLogScope
65
+ details?: unknown
66
+ code?: string
67
+ }
68
+ export const hostLogQuerySchema = z
69
+ .object({
70
+ levels: z.array(hostLogLevelSchema).max(4).optional(),
71
+ sourceKinds: z.array(hostLogSourceKindSchema).max(5).optional(),
72
+ sourceIds: z.array(z.string().max(512)).max(100).optional(),
73
+ sources: z
74
+ .array(hostLogSourceSchema.pick({ kind: true, id: true }))
75
+ .max(100)
76
+ .optional(),
77
+ scope: hostLogScopeSchema.optional(),
78
+ keyword: z.string().max(1000).optional(),
79
+ from: z.iso.datetime().optional(),
80
+ to: z.iso.datetime().optional(),
81
+ olderCursor: z.string().max(128).optional(),
82
+ afterCursor: z.string().max(128).optional(),
83
+ headCursor: z.string().max(128).optional(),
84
+ limit: z.number().int().min(1).max(500).optional(),
85
+ })
86
+ .strict()
87
+ export type HostLogQuery = z.infer<typeof hostLogQuerySchema>
88
+ export const hostLogPageSchema = z
89
+ .object({
90
+ entries: z.array(hostLogEntrySchema),
91
+ olderCursor: z.string().nullable(),
92
+ headCursor: z.string(),
93
+ hasMore: z.boolean(),
94
+ gap: z.enum(['expired', 'reset']).optional(),
95
+ })
96
+ .strict()
97
+ export type HostLogPage = z.infer<typeof hostLogPageSchema>
98
+ export const hostLogSettingsSchema = z
99
+ .object({
100
+ retentionDays: z.number().int().min(1).max(30),
101
+ maxSizeMiB: z.number().int().min(64).max(2048),
102
+ revision: z.number().int().nonnegative(),
103
+ })
104
+ .strict()
105
+ export type HostLogSettings = z.infer<typeof hostLogSettingsSchema>
106
+ export const hostLogSettingsUpdateSchema = hostLogSettingsSchema
107
+ export const hostLogDebugRequestSchema = z
108
+ .object({
109
+ source: hostLogSourceSchema.pick({ kind: true, id: true }).optional(),
110
+ durationMinutes: z.union([z.literal(5), z.literal(15), z.literal(30)]).default(15),
111
+ })
112
+ .strict()
113
+ export type HostLogDebugRequest = z.infer<typeof hostLogDebugRequestSchema>
114
+ export const hostLogDebugLeaseSchema = hostLogDebugRequestSchema.extend({ id: z.string(), expiresAt: z.iso.datetime() })
115
+ export type HostLogDebugLease = z.infer<typeof hostLogDebugLeaseSchema>
116
+ export const hostLogStatusSchema = z
117
+ .object({
118
+ state: z.enum(['ready', 'degraded', 'closed']),
119
+ runId: z.string(),
120
+ headCursor: z.string(),
121
+ bytes: z.number().nonnegative(),
122
+ count: z.number().int().nonnegative(),
123
+ oldestTimestamp: z.iso.datetime().nullable(),
124
+ newestTimestamp: z.iso.datetime().nullable(),
125
+ queuedBytes: z.number().nonnegative(),
126
+ droppedCount: z.number().int().nonnegative(),
127
+ debugLeases: z.array(hostLogDebugLeaseSchema),
128
+ error: z.string().optional(),
129
+ })
130
+ .strict()
131
+ export type HostLogStatus = z.infer<typeof hostLogStatusSchema>
132
+ export const hostLogStreamEventSchema = z.discriminatedUnion('type', [
133
+ z.object({ type: z.literal('entries'), entries: z.array(hostLogEntrySchema), cursor: z.string() }),
134
+ z.object({ type: z.literal('gap'), reason: z.enum(['expired', 'reset', 'overflow']), cursor: z.string() }),
135
+ z.object({ type: z.literal('status'), status: hostLogStatusSchema }),
136
+ ])
137
+ export type HostLogStreamEvent = z.infer<typeof hostLogStreamEventSchema>
138
+ export type HostLogExportFormat = 'text' | 'jsonl'
@@ -124,7 +124,7 @@ export const ClientNotificationSchema = z
124
124
  route: z
125
125
  .string()
126
126
  .regex(
127
- /^\/(?:(?:live|channels|agents|workshop|wiring|settings|apps|work|connections|users|extensions)(?:\/[^?#]*)?)?$/u,
127
+ /^\/(?:(?:live|channels|agents|workshop|wiring|settings|community|apps|work|connections|users|extensions)(?:\/[^?#]*)?)?$/u,
128
128
  )
129
129
  .optional(),
130
130
  })