@sudobility/screenwriter_types 0.1.3 → 0.1.4

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.
@@ -69,6 +69,10 @@ export declare const API_ROUTES: {
69
69
  readonly apiKeyUpdate: RouteSpec;
70
70
  readonly apiKeyRevoke: RouteSpec;
71
71
  readonly aiStatus: RouteSpec;
72
+ readonly aiGenerateCharacterSkeleton: RouteSpec;
73
+ readonly aiGenerateScript: RouteSpec;
74
+ readonly aiPolishCharacterDialogue: RouteSpec;
75
+ readonly aiPolishScene: RouteSpec;
72
76
  readonly aiJobCreate: RouteSpec;
73
77
  readonly aiJobsList: RouteSpec;
74
78
  readonly aiJobGet: RouteSpec;
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from './formats/index.js';
20
20
  export * from './io/index.js';
21
21
  export * from './keys/index.js';
22
22
  export * from './ai/index.js';
23
+ export * from './ai/actions.js';
23
24
  export * from './jobs/index.js';
24
25
  export * from './reads/index.js';
25
26
  export * from './reports/index.js';
package/dist/index.js CHANGED
@@ -337,6 +337,15 @@ const API_ROUTES = {
337
337
  // B7 AI: script review and polish. Keys need the `ai` flag (403 AI_KEY_NOT_PERMITTED) and, to start
338
338
  // jobs or decide suggestions, read_write scope.
339
339
  aiStatus: r("GET", "/ai/status", "U,Kr"),
340
+ // Synchronous AI actions (`ai/actions.ts`): user principals only, gated by AI consent, a daily limit and credits.
341
+ aiGenerateCharacterSkeleton: r(
342
+ "POST",
343
+ "/ai/generate-character-skeleton",
344
+ "U"
345
+ ),
346
+ aiGenerateScript: r("POST", "/ai/generate-script", "U"),
347
+ aiPolishCharacterDialogue: r("POST", "/ai/polish-character-dialogue", "U"),
348
+ aiPolishScene: r("POST", "/ai/polish-scene", "U"),
340
349
  aiJobCreate: r("POST", "/documents/:did/ai/jobs", "U,Krw", "ai.run"),
341
350
  aiJobsList: r("GET", "/documents/:did/ai/jobs", "U,Kr", "document.read"),
342
351
  aiJobGet: r("GET", "/ai/jobs/:jobId", "U,Kr", "document.read"),
@@ -1989,6 +1998,200 @@ const suggestionDecideSchema = z.object({
1989
1998
  expectedHashes: z.record(z.string(), z.string()).optional(),
1990
1999
  dryRun: z.boolean().optional()
1991
2000
  });
2001
+ const AI_ACTIONS = [
2002
+ "generate-character-skeleton",
2003
+ "generate-script",
2004
+ "polish-character-dialogue",
2005
+ "polish-scene"
2006
+ ];
2007
+ const aiActionSchema = z.enum(AI_ACTIONS);
2008
+ const AI_ACTION_LIMITS = {
2009
+ /** Free-form text a writer pastes in: a character description, or the story to turn into a script. */
2010
+ descriptionMax: 8e3,
2011
+ storyMax: 3e4,
2012
+ skeletonFieldMax: 1e3,
2013
+ characterNameMax: 80,
2014
+ languageMax: 35,
2015
+ /** Dialogue polish: one character's lines. */
2016
+ dialoguesMax: 100,
2017
+ dialogueTextMax: 2e3,
2018
+ /** Scene polish. */
2019
+ sceneElementsMax: 300,
2020
+ sceneElementTextMax: 2e3,
2021
+ sceneCharactersMax: 20,
2022
+ /** Script generation output. */
2023
+ scenesMax: 40,
2024
+ elementsPerSceneMax: 200,
2025
+ elementTextMax: 2e3,
2026
+ titleMax: 120,
2027
+ locationMax: 120,
2028
+ timeMax: 40,
2029
+ idMax: 64
2030
+ };
2031
+ const CHARACTER_SKELETON_FIELDS = {
2032
+ physical: [
2033
+ "age",
2034
+ "race",
2035
+ "height",
2036
+ "weight",
2037
+ "appearance",
2038
+ "sexOrientationExperience",
2039
+ "posture",
2040
+ "unusualCharacteristics",
2041
+ "health"
2042
+ ],
2043
+ social: [
2044
+ "occupationAndAttitude",
2045
+ "education",
2046
+ "money",
2047
+ "class",
2048
+ "relationships",
2049
+ "homeLife",
2050
+ "religion",
2051
+ "placeInCommunity",
2052
+ "politics",
2053
+ "interests"
2054
+ ],
2055
+ psychological: [
2056
+ "attitudeTowardLife",
2057
+ "moralStandard",
2058
+ "intelligence",
2059
+ "ambitions",
2060
+ "frustrations",
2061
+ "fearsAndObsessions",
2062
+ "extrovertOrIntrovert",
2063
+ "specialQualities",
2064
+ "proudestAchievement",
2065
+ "greatestSorrow",
2066
+ "greatestShame",
2067
+ "noticedFirst",
2068
+ "secret",
2069
+ "noticedLast",
2070
+ "coreContradictions",
2071
+ "deepestDesire"
2072
+ ]
2073
+ };
2074
+ const CHARACTER_SKELETON_KEYS = [
2075
+ ...CHARACTER_SKELETON_FIELDS.physical,
2076
+ ...CHARACTER_SKELETON_FIELDS.social,
2077
+ ...CHARACTER_SKELETON_FIELDS.psychological
2078
+ ];
2079
+ const skeletonText = z.string().max(AI_ACTION_LIMITS.skeletonFieldMax);
2080
+ const characterSkeletonSchema = z.object({
2081
+ age: skeletonText.min(1),
2082
+ ...Object.fromEntries(
2083
+ CHARACTER_SKELETON_KEYS.filter((k) => k !== "age").map((k) => [
2084
+ k,
2085
+ skeletonText.optional()
2086
+ ])
2087
+ )
2088
+ });
2089
+ const characterSkeletonModelSchema = z.strictObject({
2090
+ age: skeletonText.min(1),
2091
+ ...Object.fromEntries(
2092
+ CHARACTER_SKELETON_KEYS.filter((k) => k !== "age").map((k) => [
2093
+ k,
2094
+ skeletonText.nullable()
2095
+ ])
2096
+ )
2097
+ });
2098
+ const SCRIPT_ELEMENT_TYPES = [
2099
+ "action",
2100
+ "character",
2101
+ "parenthetical",
2102
+ "dialogue",
2103
+ "transition"
2104
+ ];
2105
+ const scriptElementSchema = z.strictObject({
2106
+ type: z.enum(SCRIPT_ELEMENT_TYPES),
2107
+ text: z.string().min(1).max(AI_ACTION_LIMITS.elementTextMax)
2108
+ });
2109
+ const SCENE_SETTINGS = ["int", "ext", "intExt"];
2110
+ const sceneHeadingSchema = z.strictObject({
2111
+ setting: z.enum(SCENE_SETTINGS),
2112
+ location: z.string().min(1).max(AI_ACTION_LIMITS.locationMax),
2113
+ /** "DAY", "NIGHT", "LATER" … as it would follow the dash in a heading. */
2114
+ time: z.string().min(1).max(AI_ACTION_LIMITS.timeMax)
2115
+ });
2116
+ const generatedSceneSchema = z.strictObject({
2117
+ heading: sceneHeadingSchema,
2118
+ elements: z.array(scriptElementSchema).min(1).max(AI_ACTION_LIMITS.elementsPerSceneMax)
2119
+ });
2120
+ const generateCharacterSkeletonRequestSchema = z.strictObject({
2121
+ /** A free-form paragraph describing the character. */
2122
+ text: z.string().trim().min(1).max(AI_ACTION_LIMITS.descriptionMax),
2123
+ /** BCP 47 tag the skeleton values are written in. Default: the language of `text`. */
2124
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2125
+ });
2126
+ const generateCharacterSkeletonModelSchema = z.strictObject({
2127
+ skeleton: characterSkeletonModelSchema
2128
+ });
2129
+ const generateCharacterSkeletonResultSchema = z.strictObject({
2130
+ skeleton: characterSkeletonSchema
2131
+ });
2132
+ const generateScriptRequestSchema = z.strictObject({
2133
+ /** The story in common language: a premise, a synopsis or a full retelling. */
2134
+ story: z.string().trim().min(1).max(AI_ACTION_LIMITS.storyMax),
2135
+ title: z.string().trim().max(AI_ACTION_LIMITS.titleMax).optional(),
2136
+ /** BCP 47 tag the script is written in. Default: the language of `story`. */
2137
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2138
+ });
2139
+ const generateScriptModelSchema = z.strictObject({
2140
+ title: z.string().max(AI_ACTION_LIMITS.titleMax).nullable(),
2141
+ scenes: z.array(generatedSceneSchema).min(1).max(AI_ACTION_LIMITS.scenesMax)
2142
+ });
2143
+ const generateScriptResultSchema = generateScriptModelSchema;
2144
+ const dialogueLineSchema = z.strictObject({
2145
+ /** The caller's own id for the line, echoed back so the result maps onto it. */
2146
+ id: z.string().min(1).max(AI_ACTION_LIMITS.idMax),
2147
+ text: z.string().min(1).max(AI_ACTION_LIMITS.dialogueTextMax)
2148
+ });
2149
+ const polishCharacterDialogueRequestSchema = z.strictObject({
2150
+ character: z.string().trim().min(1).max(AI_ACTION_LIMITS.characterNameMax),
2151
+ skeleton: characterSkeletonSchema,
2152
+ /** One character's lines, in script order. */
2153
+ dialogues: z.array(dialogueLineSchema).min(1).max(AI_ACTION_LIMITS.dialoguesMax),
2154
+ /** How much to change; default `medium`. */
2155
+ intensity: z.enum(["light", "medium", "bold"]).optional(),
2156
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2157
+ });
2158
+ const polishCharacterDialogueModelSchema = z.strictObject({
2159
+ /** The same ids in the same order, each with the polished line. */
2160
+ dialogues: z.array(dialogueLineSchema).min(1).max(AI_ACTION_LIMITS.dialoguesMax)
2161
+ });
2162
+ const polishCharacterDialogueResultSchema = polishCharacterDialogueModelSchema;
2163
+ const sceneCharacterSchema = z.strictObject({
2164
+ /** The name as it appears in the script's character cues. */
2165
+ name: z.string().trim().min(1).max(AI_ACTION_LIMITS.characterNameMax),
2166
+ skeleton: characterSkeletonSchema
2167
+ });
2168
+ const polishSceneRequestSchema = z.strictObject({
2169
+ scene: z.strictObject({
2170
+ /** The scene heading as text, e.g. "INT. LAB - DAY". Context only: it is not rewritten. */
2171
+ heading: z.string().max(AI_ACTION_LIMITS.locationMax + AI_ACTION_LIMITS.timeMax + 16).optional(),
2172
+ elements: z.array(scriptElementSchema).min(1).max(AI_ACTION_LIMITS.sceneElementsMax)
2173
+ }),
2174
+ /** A skeleton for every character involved in the scene. */
2175
+ characters: z.array(sceneCharacterSchema).min(1).max(AI_ACTION_LIMITS.sceneCharactersMax),
2176
+ intensity: z.enum(["light", "medium", "bold"]).optional(),
2177
+ language: z.string().max(AI_ACTION_LIMITS.languageMax).optional()
2178
+ });
2179
+ const polishSceneModelSchema = z.strictObject({
2180
+ elements: z.array(scriptElementSchema).min(1).max(AI_ACTION_LIMITS.sceneElementsMax)
2181
+ });
2182
+ const polishSceneResultSchema = polishSceneModelSchema;
2183
+ const AI_ACTION_MODEL_SCHEMAS = {
2184
+ "generate-character-skeleton": generateCharacterSkeletonModelSchema,
2185
+ "generate-script": generateScriptModelSchema,
2186
+ "polish-character-dialogue": polishCharacterDialogueModelSchema,
2187
+ "polish-scene": polishSceneModelSchema
2188
+ };
2189
+ const AI_ACTION_REQUEST_SCHEMAS = {
2190
+ "generate-character-skeleton": generateCharacterSkeletonRequestSchema,
2191
+ "generate-script": generateScriptRequestSchema,
2192
+ "polish-character-dialogue": polishCharacterDialogueRequestSchema,
2193
+ "polish-scene": polishSceneRequestSchema
2194
+ };
1992
2195
  const JOB_STATUSES = [
1993
2196
  "queued",
1994
2197
  "running",
@@ -4000,6 +4203,10 @@ export {
4000
4203
  ACCOUNT_EXPORT_FILENAME,
4001
4204
  ACTIVITY_KINDS,
4002
4205
  ACTOR_KINDS,
4206
+ AI_ACTIONS,
4207
+ AI_ACTION_LIMITS,
4208
+ AI_ACTION_MODEL_SCHEMAS,
4209
+ AI_ACTION_REQUEST_SCHEMAS,
4003
4210
  AI_CONSENT_VERSION,
4004
4211
  AI_ENDPOINTS,
4005
4212
  AI_ENDPOINT_OUTPUT_SCHEMAS,
@@ -4031,6 +4238,8 @@ export {
4031
4238
  AUDIT_MAX_RANGE_DAYS,
4032
4239
  AUTOCORRECT_MAX_PAIRS,
4033
4240
  BATCH_WATERMARK_MAX_RECIPIENTS,
4241
+ CHARACTER_SKELETON_FIELDS,
4242
+ CHARACTER_SKELETON_KEYS,
4034
4243
  CHAT_BODY_MAX,
4035
4244
  CHAT_EDIT_WINDOW_MINUTES,
4036
4245
  CLIENT_AUTO_REASONS,
@@ -4101,6 +4310,8 @@ export {
4101
4310
  ROLES,
4102
4311
  ROLE_PERMISSIONS,
4103
4312
  SCENE_BATCH_MAX,
4313
+ SCENE_SETTINGS,
4314
+ SCRIPT_ELEMENT_TYPES,
4104
4315
  SEARCH_HIT_TYPES,
4105
4316
  SEVERITIES,
4106
4317
  SHARE_LINK_ACCESS,
@@ -4158,6 +4369,7 @@ export {
4158
4369
  adminJobKindPatchSchema,
4159
4370
  adminJobListQuerySchema,
4160
4371
  adminJobRefundSchema,
4372
+ aiActionSchema,
4161
4373
  aiConsentAcceptSchema,
4162
4374
  aiEndpointInputSchema,
4163
4375
  aiEstimateRequestSchema,
@@ -4196,6 +4408,7 @@ export {
4196
4408
  changesQuerySchema,
4197
4409
  characterPacketBodySchema,
4198
4410
  characterPacketSchema,
4411
+ characterSkeletonSchema,
4199
4412
  chatMessageCreateSchema,
4200
4413
  chatMessageUpdateSchema,
4201
4414
  chatQuerySchema,
@@ -4211,6 +4424,7 @@ export {
4211
4424
  defaultNotificationPrefs,
4212
4425
  deviceCreateSchema,
4213
4426
  deviceUpdateSchema,
4427
+ dialogueLineSchema,
4214
4428
  dictionaryUpdateSchema,
4215
4429
  docSourceSchema,
4216
4430
  documentApplyTemplateSchema,
@@ -4242,6 +4456,13 @@ export {
4242
4456
  exportJobInputSchema,
4243
4457
  exportOptionsSchema,
4244
4458
  fountainQuerySchema,
4459
+ generateCharacterSkeletonModelSchema,
4460
+ generateCharacterSkeletonRequestSchema,
4461
+ generateCharacterSkeletonResultSchema,
4462
+ generateScriptModelSchema,
4463
+ generateScriptRequestSchema,
4464
+ generateScriptResultSchema,
4465
+ generatedSceneSchema,
4245
4466
  grantUpdateSchema,
4246
4467
  hasPermission,
4247
4468
  idKind,
@@ -4283,7 +4504,13 @@ export {
4283
4504
  packetQuerySchema,
4284
4505
  parseReportOptions,
4285
4506
  pingPayloadSchema,
4507
+ polishCharacterDialogueModelSchema,
4508
+ polishCharacterDialogueRequestSchema,
4509
+ polishCharacterDialogueResultSchema,
4286
4510
  polishResponseSchema,
4511
+ polishSceneModelSchema,
4512
+ polishSceneRequestSchema,
4513
+ polishSceneResultSchema,
4287
4514
  projectBinCreateSchema,
4288
4515
  projectCreateSchema,
4289
4516
  projectDuplicateJobInputSchema,
@@ -4312,9 +4539,12 @@ export {
4312
4539
  roleAtLeast,
4313
4540
  roleChangedPayloadSchema,
4314
4541
  roleSchema,
4542
+ sceneCharacterSchema,
4543
+ sceneHeadingSchema,
4315
4544
  scenePacketBodySchema,
4316
4545
  scenePacketSchema,
4317
4546
  scenesBatchRequestSchema,
4547
+ scriptElementSchema,
4318
4548
  searchQuerySchema,
4319
4549
  serverShutdownPayloadSchema,
4320
4550
  shareLinkCreateSchema,